:root {
    --bg: #f3efe5;
    --panel: rgba(255, 251, 245, 0.94);
    --panel-strong: #fffdf8;
    --text: #1f1b16;
    --muted: #6d6258;
    --primary: #d9682f;
    --primary-dark: #a94a1c;
    --accent: #2c6e49;
    --border: rgba(31, 27, 22, 0.08);
    --shadow: 0 18px 50px rgba(75, 52, 31, 0.12);
    --radius: 24px;
}

* {
    box-sizing: border-box;
}

html {
    background:
        radial-gradient(circle at top, rgba(217, 104, 47, 0.18), transparent 32%),
        linear-gradient(180deg, #fbf4e7 0%, #efe4d3 100%);
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--text);
    font-family: "Avenir Next", "Segoe UI", sans-serif;
}

button,
textarea {
    font: inherit;
}

.app-shell {
    width: min(100%, 42rem);
    margin: 0 auto;
    padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom));
}

.hero {
    padding: 1.5rem 0 1rem;
}

.hero h1,
.section-heading h2,
.player-card h3 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    letter-spacing: -0.03em;
}

.hero h1 {
    font-size: clamp(2.4rem, 7vw, 4rem);
    line-height: 0.95;
}

.hero-copy,
.player-card p,
.history-card p,
.history-card small,
.empty-state,
label,
.section-heading span,
.eyebrow {
    color: var(--muted);
}

.eyebrow {
    margin: 0 0 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.75rem;
    font-weight: 700;
}

.panel {
    background: var(--panel);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}

.panel-error {
    border-color: rgba(155, 45, 45, 0.22);
    background: rgba(255, 236, 231, 0.95);
}

.panel-success {
    border-color: rgba(44, 110, 73, 0.25);
    background: rgba(234, 248, 239, 0.95);
}

.section-heading,
.status-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.turn-badge {
    display: grid;
    place-items: center;
    min-width: 4.5rem;
    min-height: 4.5rem;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary), #f29f54);
    color: white;
    font-size: 1.35rem;
    font-weight: 700;
}

.stack-form {
    display: grid;
    gap: 0.8rem;
}

textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--panel-strong);
    padding: 0.95rem 1rem;
    resize: vertical;
    min-height: 9rem;
}

.primary-button,
.secondary-button,
.danger-button,
.score-button {
    appearance: none;
    border: 0;
    border-radius: 18px;
    cursor: pointer;
    transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.primary-button {
    background: linear-gradient(135deg, var(--primary), #f08d49);
    color: white;
    font-weight: 700;
    padding: 0.95rem 1.1rem;
}

.secondary-button {
    background: rgba(31, 27, 22, 0.06);
    color: var(--text);
    padding: 0.7rem 0.9rem;
}

.danger-button {
    background: rgba(155, 45, 45, 0.12);
    color: #8e1f1f;
    padding: 0.6rem 0.9rem;
    border: 1px solid rgba(155, 45, 45, 0.16);
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.7rem;
}

.score-button {
    min-height: 4rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    background: var(--panel-strong);
    border: 1px solid var(--border);
}

.score-button:active,
.primary-button:active,
.secondary-button:active,
.danger-button:active {
    transform: scale(0.98);
}

.player-list,
.history-list,
.throw-list {
    display: grid;
    gap: 0.8rem;
}

.player-card,
.history-card,
.throw-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(31, 27, 22, 0.05);
    border-radius: 20px;
    padding: 0.95rem 1rem;
}

.player-card-active {
    background: linear-gradient(135deg, rgba(217, 104, 47, 0.15), rgba(242, 159, 84, 0.12));
    border-color: rgba(217, 104, 47, 0.28);
}

.player-card strong {
    font-size: 2rem;
    line-height: 1;
}

.inline-actions {
    display: flex;
    gap: 0.6rem;
}

.history-card,
.throw-row {
    align-items: flex-start;
    flex-direction: column;
}

.history-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
}

.history-footer {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.history-footer form {
    margin: 0;
}

@media (min-width: 700px) {
    .app-shell {
        padding-top: 2rem;
    }

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