:root {
    --bg-primary: #12141c;
    --bg-secondary: #1b1f2b;
    --bg-card: #252b3a;
    --text-primary: #eef1f7;
    --text-secondary: #9aa3b8;
    --accent-primary: #7c9cff;
    --accent-hover: #96b0ff;
    --accent-even: #5ed3a0;
    --accent-odd: #f2b263;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100dvh;
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
}

#app {
    width: 100vw;
    height: 100dvh;
    position: relative;
}

.even-word { color: var(--accent-even); }
.odd-word { color: var(--accent-odd); }

/* Screens */
.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex;
}

/* Main Menu */
.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 24px;
}

.logo {
    text-align: center;
    max-width: 340px;
}

.logo-tiles {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 18px;
}

.logo-tiles span {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: #1b1f2b;
    background: linear-gradient(160deg, #f5f7fb, #dbe1ee);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.logo h1 {
    font-size: 40px;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.tagline {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.5;
}

.tagline strong {
    font-weight: 700;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 260px;
}

/* Buttons */
.btn {
    border: none;
    border-radius: var(--radius);
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.08s, background 0.15s, opacity 0.15s;
    color: var(--text-primary);
    background: var(--bg-card);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent-primary);
    color: #12141c;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-card);
}

.btn-secondary:hover {
    background: #2f3648;
}

.btn-tertiary {
    background: transparent;
    color: var(--text-secondary);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

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

.btn-large {
    padding: 18px 20px;
    font-size: 18px;
}

[hidden] {
    display: none !important;
}

.btn-control {
    background: var(--bg-card);
    padding: 12px 18px;
    font-size: 15px;
}

.btn-control:hover {
    background: #2f3648;
}

.btn-control.active {
    background: var(--accent-primary);
    color: #12141c;
}

.btn-back {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    font-family: inherit;
    cursor: pointer;
    padding: 8px;
}

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

.info-container .btn-back {
    align-self: flex-start;
}

/* Setup panel (Custom screen) */
.setup {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 18px;
    width: 100%;
}

.setup-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.setup-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.setup-hint {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.setup-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 2px 0;
}

.setup-divider::before,
.setup-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.text-input {
    width: 100%;
    background: var(--bg-card);
    border: none;
    border-radius: 10px;
    padding: 13px 14px;
    font-family: inherit;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.text-input:focus {
    box-shadow: inset 0 0 0 2px var(--accent-primary);
}

.input-error {
    color: var(--accent-odd);
    font-size: 13px;
    text-align: center;
}

.stepper {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
}

.stepper button {
    border: none;
    background: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    width: 34px;
    height: 34px;
    cursor: pointer;
    transition: background 0.12s, opacity 0.12s;
}

.stepper button:hover:not(:disabled) {
    background: #333c50;
}

.stepper button:disabled {
    opacity: 0.28;
    cursor: default;
}

.stepper-value {
    min-width: 30px;
    text-align: center;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* How it works */
.info-container {
    width: min(92vw, 480px);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.info-container h2 {
    font-size: 28px;
}

.rules {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rule-item {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--radius);
}

.rule-item.highlight {
    box-shadow: inset 0 0 0 1px rgba(124, 156, 255, 0.35);
}

.rule-num {
    flex: 0 0 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: #12141c;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.rule-item p {
    color: var(--text-secondary);
    line-height: 1.55;
    font-size: 15px;
}

.rule-item strong {
    color: var(--text-primary);
}

.rule-item strong.even-word { color: var(--accent-even); }
.rule-item strong.odd-word { color: var(--accent-odd); }

/* Game screen */
#game-screen {
    justify-content: flex-start;
    padding: 18px 16px;
    gap: 12px;
}

.game-header {
    width: min(94vw, 560px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.hud {
    display: flex;
    gap: 8px;
}

.hud-item {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 88px;
}

.hud-item.parity.is-even { box-shadow: inset 0 0 0 1px rgba(94, 211, 160, 0.5); }
.hud-item.parity.is-odd { box-shadow: inset 0 0 0 1px rgba(242, 178, 99, 0.5); }

.hud-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.hud-value {
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.parity.is-even .hud-value { color: var(--accent-even); }
.parity.is-odd .hud-value { color: var(--accent-odd); }

/* Board + arrow overlay */
.board-wrap {
    width: min(94vw, 640px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.board-area {
    position: relative;
    width: 100%;
    padding: 84px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.arrows {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
    z-index: 2;
}

.board {
    --tile: 60px;
    position: relative;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    z-index: 1;
}

.tile {
    width: var(--tile);
    border: none;
    background: none;
    padding: 0;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.tile-face {
    --cycle: transparent;
    width: var(--tile);
    height: var(--tile);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #f5f7fb, #dbe1ee);
    color: #1b1f2b;
    font-size: calc(var(--tile) * 0.42);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
    transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
}

.tile-slot {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.tile:hover .tile-face {
    background: linear-gradient(160deg, #ffffff, #e9eef8);
}

.tile.selected .tile-face {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 0 0 3px var(--accent-primary);
    transform: translateY(-4px);
}

.tile.in-cycle .tile-face {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), inset 0 0 0 3px var(--cycle);
}

@keyframes tile-pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.16); }
    100% { transform: scale(1); }
}

.tile.pop .tile-face {
    animation: tile-pop 220ms ease-out;
}

.board-hint {
    font-size: 13px;
    color: var(--text-secondary);
    min-height: 18px;
}

/* Cycle read-out */
.cycle-panel {
    width: min(94vw, 560px);
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cycle-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.cycle-chip {
    --cycle: var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border-radius: 999px;
    padding: 6px 6px 6px 14px;
    font-size: 14px;
    box-shadow: inset 3px 0 0 var(--cycle);
}

.cycle-cycle {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.cycle-cost {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: 999px;
    padding: 3px 9px;
}

.cycle-verdict {
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.cycle-verdict strong { color: var(--text-primary); }
.cycle-verdict strong.even-word { color: var(--accent-even); }
.cycle-verdict strong.odd-word { color: var(--accent-odd); }

.game-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}
