:root {
    --bg: #f7f2ea;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-strong: #ffffff;
    --ink: #19212e;
    --muted: #657082;
    --line: #e4dfd7;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #f59e0b;
    --danger: #c2410c;
    --success: #15803d;
    --shadow: 0 24px 70px rgba(32, 40, 52, 0.16);
    --soft-shadow: 0 14px 35px rgba(32, 40, 52, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 34rem),
        linear-gradient(135deg, #fffaf2 0%, var(--bg) 44%, #eef7f4 100%);
}

button {
    border: 0;
    font: inherit;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

button:not(:disabled):active {
    transform: translateY(1px) scale(0.99);
}

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

.hero-panel {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 16px;
    padding: 22px 26px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 30px;
    background:
        linear-gradient(135deg, rgba(25, 33, 46, 0.94), rgba(17, 94, 89, 0.88)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='160' viewBox='0 0 240 160'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.12' stroke-width='2'%3E%3Cpath d='M20 120C80 20 150 180 220 50'/%3E%3Cpath d='M-10 64h260M72-20v210M168-10v180'/%3E%3C/g%3E%3Ccircle cx='198' cy='36' r='18' fill='%23f59e0b' fill-opacity='.35'/%3E%3C/svg%3E");
    background-size: cover;
    box-shadow: var(--shadow);
    color: #ffffff;
}

.hero-copy {
    max-width: 600px;
}

.eyebrow,
.section-kicker {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-panel .eyebrow {
    color: #a7f3d0;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: clamp(2.1rem, 4.8vw, 3.8rem);
    line-height: 1;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 0;
    font-size: 1.35rem;
    line-height: 1.2;
}

.hero-text {
    max-width: 500px;
    margin-bottom: 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 1rem;
    line-height: 1.5;
}

.score-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    align-self: flex-start;
    min-width: 280px;
    margin-top: 2px;
    padding: 13px 16px;
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(16px);
}

.score-label {
    display: block;
    margin-bottom: 0;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.score-card strong {
    color: #ffffff;
    font-size: 1.05rem;
    line-height: 1.1;
    text-align: right;
    white-space: nowrap;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 22px;
    align-items: start;
}

.card {
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 26px;
    background: var(--surface);
    box-shadow: var(--soft-shadow);
    backdrop-filter: blur(18px);
}

.game-card,
.history-card,
.how-to-card {
    padding: 24px;
}

.game-card-header,
.card-title-row,
.action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.guess-display {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin: 28px 0 14px;
}

.digit-slot {
    display: grid;
    min-height: 98px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    box-shadow: inset 0 -10px 24px rgba(15, 118, 110, 0.06);
    color: var(--ink);
    font-size: clamp(2.1rem, 9vw, 3.7rem);
    font-weight: 800;
}

.message {
    min-height: 26px;
    margin-bottom: 20px;
    color: var(--muted);
    font-weight: 600;
}

.message.error {
    color: var(--danger);
}

.message.success {
    color: var(--success);
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.number-button,
.secondary-button,
.primary-button,
.ghost-button {
    min-height: 54px;
    border-radius: 16px;
    font-weight: 800;
}

.number-button {
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--ink);
    font-size: 1.35rem;
    box-shadow: 0 8px 18px rgba(32, 40, 52, 0.08);
}

.number-button:not(:disabled):hover {
    background: #eefdfa;
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.13);
    transform: translateY(-2px);
}

.number-button.used {
    background: #e8ecef;
    color: #98a1ad;
}

.action-row {
    margin-top: 16px;
}

.secondary-button,
.ghost-button {
    padding: 0 18px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--ink);
}

.secondary-button {
    flex: 1;
}

.primary-button {
    flex: 1.25;
    padding: 0 22px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #ffffff;
    box-shadow: 0 14px 28px rgba(15, 118, 110, 0.22);
}

.primary-button:not(:disabled):hover,
.secondary-button:not(:disabled):hover,
.ghost-button:not(:disabled):hover {
    transform: translateY(-2px);
}

.win-panel {
    margin-top: 22px;
    padding: 22px;
    border: 1px solid rgba(21, 128, 61, 0.2);
    border-radius: 22px;
    background: linear-gradient(135deg, rgba(236, 253, 245, 0.96), rgba(255, 251, 235, 0.96));
    animation: riseIn 320ms ease both;
}

.win-panel p {
    margin: 10px 0 18px;
    color: var(--muted);
}

.spark {
    display: inline-flex;
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.18);
    color: #92400e;
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.is-hidden {
    display: none;
}

.attempt-count {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 15px;
    background: #ecfdf5;
    color: var(--primary-dark);
    font-weight: 900;
}

.history-empty {
    margin-top: 24px;
    padding: 24px;
    border: 1px dashed #cbd5e1;
    border-radius: 18px;
    color: var(--muted);
    text-align: center;
}

.history-list {
    display: grid;
    gap: 10px;
    margin-top: 22px;
}

.history-item {
    display: grid;
    grid-template-columns: 64px 1fr 1.4fr;
    gap: 10px;
    align-items: center;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
    animation: slideIn 220ms ease both;
}

.history-item span {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.history-guess {
    color: var(--ink);
    font-size: 1.1rem;
    font-weight: 900;
}

.history-result {
    justify-self: end;
    color: var(--primary-dark);
    font-weight: 900;
    text-align: right;
}

.how-to-card {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    margin-top: 22px;
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.rules-grid p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}

.rules-grid .example {
    color: var(--ink);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 920px) {
    .hero-panel,
    .game-layout,
    .how-to-card,
    .rules-grid {
        grid-template-columns: 1fr;
    }

    .hero-panel {
        display: grid;
        gap: 14px;
    }

    .score-card {
        width: 100%;
        min-width: 0;
        margin-top: 0;
    }
}

@media (max-width: 620px) {
    .app-shell {
        width: min(100% - 22px, 1180px);
        padding: 10px 0 18px;
    }

    .hero-panel,
    .game-card,
    .history-card,
    .how-to-card {
        padding: 18px;
        border-radius: 22px;
    }

    .hero-panel {
        margin-bottom: 12px;
        padding: 15px 16px;
    }

    h1 {
        margin-bottom: 8px;
        font-size: clamp(1.55rem, 8vw, 2.1rem);
        line-height: 1.05;
    }

    .hero-text {
        font-size: 0.95rem;
        line-height: 1.4;
    }

    .score-card {
        gap: 12px;
        padding: 11px 13px;
        border-radius: 16px;
    }

    .score-card strong {
        font-size: 0.98rem;
    }

    .game-card-header,
    .card-title-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .ghost-button {
        width: 100%;
    }

    .digit-slot {
        min-height: 82px;
        border-radius: 18px;
    }

    .action-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .primary-button {
        grid-column: 1 / -1;
    }

    .history-item {
        grid-template-columns: 48px 1fr;
    }

    .history-result {
        grid-column: 1 / -1;
        justify-self: start;
        text-align: left;
    }
}
