:root {
    --bg-color: #282c24; /* Obra Dinn Dark */
    --card-bg: #282c24;
    --text-primary: #e3e4d5; /* Obra Dinn Light */
    --text-secondary: #e3e4d5;
    --accent: #e3e4d5;
    --accent-hover: #282c24;
    --success: #e3e4d5;
    --error: #e3e4d5;
    --border: #e3e4d5;
    --shadow: #e3e4d5;
}

[data-theme="light"] {
    --bg-color: #e3e4d5;
    --card-bg: #e3e4d5;
    --text-primary: #282c24;
    --text-secondary: #282c24;
    --accent: #282c24;
    --accent-hover: #e3e4d5;
    --success: #282c24;
    --error: #282c24;
    --border: #282c24;
    --shadow: #282c24;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-smooth: never;
    -webkit-font-smoothing: none;
}

body {
    font-family: 'VT323', monospace;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Dither overlay */
body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    /* 2x2 Dither Pattern SVG Data URI */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4"><rect width="2" height="2" fill="rgba(0,0,0,0.15)"/><rect x="2" y="2" width="2" height="2" fill="rgba(0,0,0,0.15)"/></svg>');
    background-repeat: repeat;
    mix-blend-mode: multiply;
}
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9998;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 50%,
        rgba(0, 0, 0, 0.1) 50%
    );
    background-size: 100% 4px;
    box-shadow: inset 0 0 100px rgba(0,0,0,0.5);
    animation: scanlines 10s linear infinite;
}
@keyframes scanlines {
    0% { background-position: 0 0; }
    100% { background-position: 0 100vh; }
}

[data-theme="light"] body::after {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4"><rect width="2" height="2" fill="rgba(0,0,0,0.1)"/><rect x="2" y="2" width="2" height="2" fill="rgba(0,0,0,0.1)"/></svg>');
}

.cursor.blinking {
    animation: blink 1s step-end infinite;
    font-weight: bold;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

#app {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.screen {
    display: none;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

h1 {
    font-size: 4rem;
    font-weight: 400;
    text-align: center;
    margin-bottom: 2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 400;
    text-transform: uppercase;
}

h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.card {
    background: var(--card-bg);
    border: 4px solid var(--border);
    border-radius: 0;
    padding: 2.5rem;
    box-shadow: 8px 8px 0 var(--shadow);
}

#theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--card-bg);
    border: 2px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 1.2rem;
    text-transform: uppercase;
    z-index: 100;
    box-shadow: 4px 4px 0 var(--shadow);
}

#theme-toggle:hover {
    background: var(--text-primary);
    color: var(--bg-color);
}

#theme-toggle:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--shadow);
}

/* Gauge Animation */
.gauge-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
    position: relative;
}
.gauge {
    width: 250px;
    height: 125px;
    position: relative;
    overflow: hidden;
}
.gauge-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 10;
    stroke-dasharray: 4 8;
}
.gauge-needle {
    transform-origin: 125px 125px;
    transition: transform 1.5s steps(20);
    transform: rotate(-90deg); /* Start at 0 */
}
.gauge-needle-line {
    stroke: var(--text-primary);
    stroke-width: 6;
}
.gauge-needle-circle {
    fill: var(--text-primary);
}
.gauge-labels {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

#gauge-val-display {
    color: var(--text-primary);
    font-size: 2.2rem;
    margin-bottom: 15px; /* Push the value up slightly into the center of the arc */
}

/* Intro Screen */
#intro-screen .card ul {
    list-style-type: square;
    list-style-position: inside;
    margin-bottom: 1.5rem;
    line-height: 1.4;
    font-size: 1.5rem;
}

#intro-screen .card ul strong {
    color: var(--text-primary);
}

.warning {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
    border: 2px dashed var(--border);
    padding: 1rem;
    text-align: center;
}

.btn {
    display: inline-block;
    padding: 1rem 2rem;
    font-size: 1.5rem;
    font-family: inherit;
    border: 4px solid var(--border);
    border-radius: 0;
    cursor: pointer;
    text-align: center;
    text-transform: uppercase;
    box-shadow: 4px 4px 0 var(--shadow);
}

.btn.primary {
    background-color: var(--card-bg);
    color: var(--text-primary);
    width: 100%;
}

.btn.primary:hover {
    background-color: var(--text-primary);
    color: var(--bg-color);
}

.btn.primary:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--shadow);
}

.btn.secondary {
    background-color: var(--card-bg);
    color: var(--text-primary);
    width: 100%;
}

.btn.secondary:hover {
    background-color: var(--text-primary);
    color: var(--bg-color);
}

.btn.secondary:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--shadow);
}

/* Game Screen */
header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    background: var(--card-bg);
    padding: 1rem 2rem;
    border: 4px solid var(--border);
    box-shadow: 4px 4px 0 var(--shadow);
}

.stat {
    font-size: 1.8rem;
}

.balance {
    font-size: 2rem;
}

.balance.negative {
    text-decoration: underline;
}

.game-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .game-container {
        grid-template-columns: 1fr;
    }
}

.subtitle {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
}

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.currency {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
}

#bid-input {
    width: 100%;
    background: var(--card-bg);
    border: 4px solid var(--border);
    padding: 1rem 1rem 1rem 2.5rem;
    font-size: 2rem;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
}

#bid-input:focus {
    background: var(--text-primary);
    color: var(--bg-color);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auto-bet-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    cursor: pointer;
    user-select: none;
    margin-top: 1rem;
}

input[type="checkbox"] {
    appearance: none;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    background: var(--card-bg);
    cursor: pointer;
}

input[type="checkbox"]:checked {
    background: var(--text-primary);
}

/* History Log */
.history-panel {
    display: flex;
    flex-direction: column;
    height: 400px;
}

.log-container {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-right: 0.5rem;
    border: 2px solid var(--border);
    padding: 1rem;
}

/* Custom Scrollbar */
.log-container::-webkit-scrollbar {
    width: 12px;
}
.log-container::-webkit-scrollbar-track {
    background: var(--card-bg);
    border-left: 2px solid var(--border);
}
.log-container::-webkit-scrollbar-thumb {
    background: var(--text-primary);
}

.log-item {
    border-bottom: 2px dashed var(--border);
    padding: 0.8rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.log-item:hover {
    z-index: 20;
}

.log-item::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 90%;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: var(--text-primary);
    color: var(--bg-color);
    padding: 0.5rem 0.8rem;
    font-size: 1.2rem;
    white-space: nowrap;
    display: none;
    z-index: 10;
    border: 2px solid var(--bg-color);
}

.log-item:hover::after {
    display: block;
    transform: translateX(-50%) translateY(5px);
}

.log-round {
    font-size: 1.5rem;
}

.log-table {
    flex-grow: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.2rem;
    text-align: left;
}

.log-col {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    white-space: nowrap;
}

.log-title {
    font-size: 0.9rem;
    text-transform: uppercase;
}

.log-val {
    font-size: 1.2rem;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.input-group input {
    background: transparent;
    border: 4px solid var(--border);
    color: var(--text-primary);
    font-family: 'VT323', monospace;
    font-size: 2rem;
    padding: 0.5rem;
    width: 120px;
    box-shadow: 4px 4px 0 var(--shadow);
}

.input-group input:focus {
    outline: none;
    background: var(--text-primary);
    color: var(--bg-color);
}

.result-loss {
    /* No strikethrough for 1-bit mode */
}

/* End Screen */
.results-card {
    text-align: center;
}

.final-balance {
    font-size: 5rem;
    margin-bottom: 0.5rem;
}

.performance-msg {
    font-size: 1.8rem;
    margin-bottom: 2rem;
}

.explanation {
    text-align: left;
    border: 2px solid var(--border);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.explanation p {
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

/* Link back to the main site (added when embedding on dayitva.github.io) */
#back-link {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 100;
    background: var(--card-bg);
    border: 2px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    font-size: 1.2rem;
    text-decoration: none;
}
#back-link:hover {
    background: var(--text-primary);
    color: var(--bg-color);
}
