:root {
    color-scheme: light;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --background: #17273e;
    --ink: #17273e;
    --muted: #64748b;
    --blue: #347be8;
    --coral: #ff806b;
    --paper: #f7f3e9;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    min-height: 100vh;
    margin: 0;
    padding: 16px;
    background: var(--background);
    color: var(--ink);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid #60a5fa; outline-offset: 3px; }
button:disabled { opacity: .5; cursor: default; }

.app-shell { width: min(100%, 540px); margin: 0 auto; }
body[data-page="home"] .app-shell { min-height: calc(100vh - 32px); display: flex; flex-direction: column; justify-content: center; }

.app-header { min-height: 54px; display: grid; place-items: center; position: relative; margin-bottom: 10px; }
.brand-lockup { display: flex; align-items: center; justify-content: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; }
.app-header h1 { color: #fff; font-size: 40px; font-weight: 900; letter-spacing: -1px; line-height: 1.1; margin: 0; }
.app-header h1 span { color: var(--coral); }
body[data-page="home"] .app-header { min-height: 154px; margin-bottom: 4px; }
body[data-page="home"] .brand-lockup { flex-direction: column; gap: 2px; }
body[data-page="home"] .brand-mark { width: 68px; height: 68px; border-radius: 16px; }
body[data-page="home"] .app-header h1 { font-size: clamp(50px, 14vw, 62px); letter-spacing: -2px; line-height: 1.16; }
.back-button { position: absolute; left: 0; top: 2px; width: 48px; height: 48px; padding: 0; border: 0; background: transparent; color: #fff; font-size: 42px; line-height: 1; }
.back-button:hover { color: #bfdbfe; }

.tagline { color: #d1d5db; text-align: center; font-size: 14px; margin: 0 0 22px; }
.home-card { position: relative; overflow: hidden; background: #2453a1; color: #fff; border-radius: 24px; padding: 22px; box-shadow: 0 12px 24px #0002; }
.home-card > :not(.route-decoration) { position: relative; z-index: 1; }
.route-decoration { position: absolute; right: -45px; top: 12px; width: 190px; height: 160px; opacity: .18; transform: rotate(-22deg); pointer-events: none; }
.route-decoration i { position: absolute; right: 54px; top: 15px; width: 92px; height: 140px; border: 3px dashed #fff; border-left: 0; border-radius: 0 50px 50px 0; }
.route-decoration b { position: absolute; right: 132px; top: 12px; width: 11px; height: 11px; border-radius: 50%; background: #fff; }
.route-decoration em { position: absolute; right: 44px; bottom: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--coral); }
.home-kicker { color: #bfdbfe; font-size: 11px; font-weight: 800; letter-spacing: 1.5px; margin: 0 0 10px; }
.home-card h2 { font-size: 27px; line-height: 1.2; margin: 0 0 8px; }
.home-card p:not(.home-kicker) { color: #dbeafe; font-size: 16px; line-height: 1.45; margin: 0 0 20px; }
.play-button { width: 100%; min-height: 50px; background: var(--coral); color: var(--ink); border: 0; border-radius: 12px; font-size: 17px; font-weight: 800; }
.play-button:hover, #playAgainButton:hover, #shareDailyButton:hover { background: #f26e59; }
.home-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.home-nav-button { min-height: 62px; border: 0; border-radius: 14px; color: var(--ink); font-size: 16px; font-weight: 800; }
.home-nav-button:hover { filter: brightness(.95); }
.mint { background: #b9e2ed; }
.lavender { background: #d5e4ff; }
.blue { background: #bfdbfe; }
.peach { background: #ffd5c8; }

.card { width: 100%; background: var(--paper); border-radius: 24px; border-top: 5px solid var(--blue); box-shadow: 0 12px 24px #0002; }
.game { padding: 18px; text-align: center; }
.game.daily-active { border-top-color: var(--blue); }
.eyebrow { color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: 1.4px; margin: 0; }
.city { font-size: clamp(24px, 6vw, 30px); line-height: 1.2; min-height: 38px; margin: 8px 0 14px; }
.city.long-city { font-size: clamp(22px, 5vw, 27px); }

.board { width: min(100%, 270px); aspect-ratio: 1; position: relative; margin: 0 auto 14px; }
.empty-board { position: absolute; inset: 0; }
.empty-row, .result-row { display: flex; gap: 6px; margin-bottom: 6px; }
.empty-row:last-child, .result-row:last-child { margin-bottom: 0; }
.empty-row i, .result-box { flex: 1; aspect-ratio: 1; border-radius: 8px; border: 2px solid #cbd5e1; min-width: 0; }
.empty-row i { display: block; }
#results { position: relative; z-index: 1; }
.result-box { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 23px; font-weight: 800; animation: reveal-tile .28s both; }
.result-box:nth-child(2) { animation-delay: .085s; }
.result-box:nth-child(3) { animation-delay: .17s; }
.result-box:nth-child(4) { animation-delay: .255s; }
.result-box:nth-child(5) { animation-delay: .34s; }
@keyframes reveal-tile { from { transform: rotateY(-90deg); opacity: .65; } to { transform: rotateY(0); opacity: 1; } }
.result-box.correct { background: #6aaa64; border-color: #6aaa64; }
.result-box.present { background: #c9b458; border-color: #c9b458; }
.result-box.absent { background: #787c7e; border-color: #787c7e; }

.guess-entry { display: flex; flex-direction: column; gap: 8px; max-width: 270px; margin: 0 auto; }
#guess { width: 100%; min-width: 0; height: 50px; border: 2px solid #60a5fa; border-radius: 11px; background: #eff6ff; color: var(--ink); font-size: 22px; font-weight: 800; letter-spacing: 9px; text-align: center; }
#guess::placeholder { color: #64748b; font-size: 16px; letter-spacing: 0; }
#guessButton { width: 100%; min-height: 44px; border: 0; border-radius: 11px; background: var(--blue); color: #fff; font-weight: 800; }
#guessButton:hover, #accountSignInButton:hover, #accountCombineButton:hover, #accountUseCloudButton:hover { background: #1d4ed8; }
#message { min-height: 22px; margin-top: 12px; font-size: 15px; font-weight: 700; }
#message:empty { display: none; }
.win-banner { width: 100%; margin: 12px auto 0; padding: 12px 15px; border: 2px dashed var(--coral); border-radius: 16px; background: #fff5e6; animation: stamp-in .4s ease-out; }
.win-banner p { margin: 0; color: #ab4937; font-size: 11px; font-weight: 900; letter-spacing: 1.4px; }
.win-banner strong { display: block; margin-top: 3px; color: var(--ink); font-size: 20px; }
.win-banner span { display: block; margin-top: 4px; color: #475569; font-size: 13px; font-weight: 700; }
@keyframes stamp-in { from { transform: scale(.82); opacity: .4; } to { transform: scale(1); opacity: 1; } }
#dailyResult { display: none; margin: 6px 0 0; padding: 9px; background: #fff7ed; border-radius: 10px; color: #92400e; font-weight: 700; }
.status { display: flex; align-items: center; justify-content: space-between; gap: 6px; border-top: 1px solid #e5e7eb; margin-top: 12px; padding-top: 10px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.status strong { color: var(--ink); }
.mode-description { flex: 1; overflow: hidden; text-overflow: ellipsis; color: var(--blue); font-size: 11px; font-weight: 800; }
.bottom-row { display: flex; justify-content: center; margin-top: 12px; }
#playAgainButton, #shareDailyButton { min-height: 44px; border: 0; border-radius: 12px; background: var(--coral); color: var(--ink); font-weight: 800; padding: 9px 24px; }
#playAgainButton { min-width: 210px; }
#shareDailyButton { display: none; margin-top: 12px; }
.game:not(.daily-active) #shareDailyButton { display: none !important; }

.info-card { padding: 22px; }
.info-card h2 { color: #1e40af; font-size: 26px; margin: 0 0 16px; }
.info-card > p { font-size: 16px; line-height: 1.5; margin: 0 0 14px; }
.mode-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 4%; row-gap: 14px; }
.mode-button { min-height: 88px; border: 2px solid #c6d7e8; border-radius: 16px; padding: 10px; background: #e9f2ff; color: var(--ink); display: flex; align-items: center; gap: 8px; text-align: left; }
.mode-button:hover { background: #d5e7ff; }
.mode-button.active { background: var(--blue); border-color: #245cb5; color: #fff; }
.mode-icon { font-size: 23px; flex: none; }
.mode-button strong { display: block; font-size: 15px; line-height: 1.2; }
.mode-button small { display: block; color: #52667f; font-size: 11px; margin-top: 3px; }
.mode-button.active small { color: #e8f0ff; }
.daily-note { color: var(--muted); margin: 18px 0 0 !important; font-size: 14px !important; }

.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat-tile { min-height: 84px; padding: 12px; border-radius: 12px; display: flex; flex-direction: column; justify-content: space-between; }
.stat-tile span { color: #475569; font-size: 12px; font-weight: 700; }
.stat-tile strong { font-size: 26px; font-weight: 900; }
.tint-blue { background: #dbeafe; }
.tint-green { background: #dcfce7; }
.tint-yellow { background: #fef3c7; }
.tint-lavender { background: #ede9fe; }
.tint-gray { background: #f1f5f9; }
#resetStatsButton { display: block; margin: 20px 0 0 auto; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 8px; background: #f8fafc; color: #475569; font-size: 13px; }
.quiet-note { color: var(--muted); font-size: 13px !important; margin-top: 16px !important; }
.rule-row { display: flex; gap: 10px; align-items: flex-start; padding: 12px; margin-bottom: 8px; border-radius: 12px; }
.rule-row span { font-size: 19px; }
.rule-row p { font-size: 15px; line-height: 1.45; margin: 0; }

.account-panel { margin-top: 16px; }
.account-panel p { overflow-wrap: anywhere; line-height: 1.5; }
#accountStatus { background: #eff6ff; color: #1e3a8a; border-radius: 12px; padding: 12px; font-weight: 700; }
.account-panel input { display: block; width: 100%; min-height: 46px; margin: 10px 0; padding: 10px 12px; border: 1px solid #94a3b8; border-radius: 10px; font-size: 16px; }
.account-panel button { display: block; width: 100%; min-height: 46px; margin: 10px 0; padding: 10px 12px; border: 0; border-radius: 10px; background: var(--blue); color: #fff; font-weight: 800; }
#accountSignOutButton { width: auto; min-height: 42px; padding: 8px 0; background: transparent; color: var(--blue); }
#accountSignOutButton:hover { text-decoration: underline; }

@media (min-width: 700px) {
    body[data-page="game"] .app-shell { width: min(100%, 620px); }
    .game { padding: 26px; }
    .board { width: min(100%, 350px); margin-bottom: 20px; }
    .empty-row, .result-row { gap: 8px; margin-bottom: 8px; }
    .result-box { font-size: 29px; }
    .guess-entry { max-width: 350px; }
    #guess { height: 54px; font-size: 28px; }
    #guessButton { min-height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
    .result-box, .win-banner { animation: none; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 390px) {
    body { padding: 10px; }
    body[data-page="home"] .app-shell { min-height: calc(100vh - 20px); }
    .game, .info-card { padding: 16px; }
    .status { font-size: 12px; }
    .mode-description { font-size: 10px; }
}
