:root {
    color-scheme: light;
    --bg: #f7f5f0;
    --surface: #ffffff;
    --ink: #24211d;
    --muted: #746d64;
    --line: #ded8cc;
    --accent: #1f7a5c;
    --accent-dark: #145640;
    --gold: #d99a2b;
    --red: #b85a48;
    --blue: #366e9d;
    --shadow: 0 18px 45px rgba(39, 34, 27, .10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        linear-gradient(135deg, rgba(31, 122, 92, .08), transparent 32rem),
        linear-gradient(225deg, rgba(217, 154, 43, .13), transparent 28rem),
        var(--bg);
    color: var(--ink);
    font-family: Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
.ghost-button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-weight: 800;
    padding: 0 16px;
    white-space: nowrap;
}

.ghost-button {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
}

button:hover {
    background: var(--accent-dark);
}

.ghost-button:hover {
    background: #f2eee6;
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.page {
    padding: 32px 0 48px;
}

.intro {
    min-height: 42vh;
    display: grid;
    align-content: center;
    gap: 18px;
}

.eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: .82rem;
    font-weight: 900;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    max-width: 780px;
    font-size: clamp(2.2rem, 6vw, 4.8rem);
    line-height: .98;
}

.intro p:not(.eyebrow),
.board-header p:not(.eyebrow) {
    max-width: 620px;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.65;
}

.quick-form {
    display: grid;
    gap: 8px;
    max-width: 620px;
}

.quick-form label,
.timer-dialog label {
    color: var(--muted);
    font-size: .9rem;
    font-weight: 800;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    padding: 0 14px;
}

.game-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.game-card,
.setup-strip > div,
.tile,
.timer-panel {
    background: rgba(255, 255, 255, .86);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.game-card {
    min-height: 124px;
    border-radius: 8px;
    display: grid;
    align-content: end;
    gap: 8px;
    padding: 18px;
}

.game-card strong {
    font-size: 1.25rem;
}

.game-card span,
.setup-strip span {
    color: var(--muted);
    font-size: .9rem;
}

.board-header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 18px;
    margin-bottom: 20px;
}

.back-link {
    display: inline-flex;
    margin-bottom: 20px;
    color: var(--muted);
    font-weight: 800;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.setup-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0;
}

.setup-strip > div {
    min-height: 84px;
    border-radius: 8px;
    display: grid;
    align-content: center;
    gap: 4px;
    padding: 14px;
}

.board {
    display: grid;
    gap: 10px;
}

.board-grid,
.board-stack {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.board-hex {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.tile {
    position: relative;
    min-height: 118px;
    border-radius: 8px;
    display: grid;
    align-content: space-between;
    gap: 12px;
    padding: 14px;
    overflow: hidden;
}

.tile:nth-child(4n + 1) {
    border-top: 4px solid var(--accent);
}

.tile:nth-child(4n + 2) {
    border-top: 4px solid var(--gold);
}

.tile:nth-child(4n + 3) {
    border-top: 4px solid var(--blue);
}

.tile:nth-child(4n) {
    border-top: 4px solid var(--red);
}

.tile-index {
    color: var(--muted);
    font-size: .82rem;
    font-weight: 800;
}

.tile strong {
    min-width: 0;
    font-size: 1.05rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.tile em {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-style: normal;
    font-weight: 900;
}

.timer-panel {
    border-radius: 8px;
    margin: 0 0 18px;
    padding: 14px;
}

.timer-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.timers {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.timer-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfaf7;
    display: grid;
    gap: 10px;
    padding: 12px;
}

.timer-card.is-active {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 2px rgba(31, 122, 92, .16);
}

.timer-time {
    font-size: 1.8rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.timer-dialog {
    width: min(360px, calc(100% - 32px));
    border: 0;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 0;
}

.timer-dialog::backdrop {
    background: rgba(20, 18, 15, .46);
}

.timer-dialog form {
    display: grid;
    gap: 12px;
    padding: 20px;
}

.dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

@media (max-width: 820px) {
    .board-header,
    .input-row {
        grid-template-columns: 1fr;
    }

    .header-actions {
        justify-content: stretch;
    }

    .header-actions > * {
        flex: 1;
    }

    .game-list,
    .setup-strip,
    .board-grid,
    .board-stack,
    .board-hex,
    .timers {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .shell {
        width: min(100% - 20px, 1120px);
    }

    .page {
        padding-top: 18px;
    }

    .game-list,
    .setup-strip,
    .board-grid,
    .board-stack,
    .board-hex,
    .timers {
        grid-template-columns: 1fr;
    }

    .tile {
        min-height: 96px;
    }
}
