* {
    box-sizing: border-box;
}

:root {
    --cream: #fff4dc;
    --chalk: #315f44;
    --chalk-soft: #6c9b60;
    --wood: #b77a45;
    --wood-dark: #7c4a2b;
    --paper: #fff9ed;
    --ink: #3b2a1d;
    --muted: #846f5a;
    --line: rgba(126, 88, 47, 0.18);
    --shadow: 0 22px 55px rgba(86, 57, 24, 0.18);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.84), transparent 22rem),
        linear-gradient(180deg, #fff8e9, var(--cream));
    font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
}

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

button,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.site-header,
.roulette-app {
    width: min(1160px, calc(100% - 24px));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 14px 0;
    backdrop-filter: blur(18px);
}

.site-header::before {
    position: fixed;
    inset: 0 0 auto;
    z-index: -1;
    height: 68px;
    content: "";
    background: rgba(255, 248, 233, 0.88);
    border-bottom: 1px solid rgba(126, 88, 47, 0.14);
}

.brand,
.site-nav {
    display: inline-flex;
    align-items: center;
}

.brand {
    gap: 0.75rem;
    font-weight: 900;
    white-space: nowrap;
}

.brand-mark {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    color: #fffdf7;
    background: var(--chalk);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(49, 95, 68, 0.18);
}

.site-nav {
    gap: 0.2rem;
    padding: 5px;
    color: var(--muted);
    background: rgba(255, 249, 237, 0.82);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.site-nav a {
    padding: 0.62rem 0.78rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
}

.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav a[aria-current="page"] {
    color: #fffdf7;
    background: var(--chalk);
    outline: 0;
}

.roulette-app {
    padding: clamp(1rem, 3vw, 2rem) 0;
}

.tool-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.eyebrow {
    margin: 0 0 0.7rem;
    color: var(--chalk-soft);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0.65rem;
    font-size: clamp(2.2rem, 7vw, 4.4rem);
    line-height: 1;
}

h2 {
    margin-bottom: 0;
    font-size: 1.1rem;
}

.tool-header p:last-child,
.hint {
    color: var(--muted);
    line-height: 1.6;
}

.tool-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 1rem;
    align-items: start;
}

.wheel-card,
.panel-card,
.result-card {
    background: rgba(255, 249, 237, 0.9);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.wheel-card {
    overflow: hidden;
    padding: clamp(0.7rem, 2vw, 1rem);
}

.wheel-wrap {
    position: relative;
    display: grid;
    place-items: center;
}

#rouletteCanvas {
    display: block;
    width: min(100%, 760px);
    height: auto;
    min-height: 520px;
    cursor: pointer;
    background: var(--chalk);
    border-radius: 8px;
}

.wheel-pointer {
    position: absolute;
    top: 4px;
    left: 50%;
    width: 0;
    height: 0;
    border-right: 22px solid transparent;
    border-left: 22px solid transparent;
    border-top: 52px solid var(--wood-dark);
    transform: translateX(-50%);
    filter: drop-shadow(0 8px 10px rgba(59, 42, 29, 0.22));
}

.result-card {
    display: grid;
    min-width: min(100%, 270px);
    gap: 0.45rem;
    padding: 1rem;
    position: relative;
    overflow: hidden;
    transition:
        background 180ms ease,
        border-color 180ms ease,
        box-shadow 180ms ease,
        transform 180ms ease;
}

.result-card span,
label,
.stat-row span {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 800;
}

.result-card strong {
    position: relative;
    z-index: 1;
    color: var(--wood-dark);
    font-size: clamp(1.5rem, 4vw, 2.3rem);
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.result-card > span {
    position: relative;
    z-index: 1;
}

.result-card.is-spinning {
    border-color: rgba(108, 155, 96, 0.48);
    box-shadow: 0 22px 55px rgba(49, 95, 68, 0.2);
}

.result-card.is-win {
    color: #153d2b;
    background: linear-gradient(135deg, #f6ffe9, #dff4cf);
    border-color: rgba(49, 95, 68, 0.42);
    box-shadow: 0 24px 64px rgba(49, 95, 68, 0.24);
    transform: translateY(-2px);
}

.result-card.is-lose {
    color: #4a251c;
    background: linear-gradient(135deg, #fff3e6, #f2d6c3);
    border-color: rgba(124, 74, 43, 0.36);
    box-shadow: 0 24px 64px rgba(124, 74, 43, 0.22);
}

.result-card.is-spinning::before {
    position: absolute;
    inset: 0;
    content: "";
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.58), transparent);
    transform: translateX(-100%);
    animation: result-sweep 1.1s infinite;
}

.result-card.is-win strong {
    color: #1f6b3f;
    font-size: clamp(2.2rem, 6vw, 4rem);
}

.result-card.is-lose strong {
    color: #8a3529;
    font-size: clamp(2rem, 5vw, 3.4rem);
}

.result-badge,
.result-note {
    position: relative;
    z-index: 1;
    margin: 0;
}

.result-badge {
    justify-self: start;
    padding: 0.28rem 0.58rem;
    color: #fffdf7;
    background: var(--chalk);
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 900;
    line-height: 1;
}

.result-card.is-win .result-badge {
    background: #1f6b3f;
}

.result-card.is-lose .result-badge {
    background: #8a3529;
}

.result-note {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.45;
}

.result-card.is-win .result-note,
.result-card.is-lose .result-note {
    color: currentColor;
}

.control-panel {
    display: grid;
    gap: 1rem;
}

.panel-card {
    display: grid;
    gap: 0.8rem;
    padding: 1rem;
}

textarea {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    padding: 0.85rem;
    color: var(--ink);
    background: #fffdf7;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
    line-height: 1.55;
}

textarea:focus {
    border-color: rgba(108, 155, 96, 0.68);
    box-shadow: 0 0 0 4px rgba(108, 155, 96, 0.12);
}

.button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.button {
    min-height: 48px;
    padding: 0.85rem 1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 900;
}

.button.primary {
    color: #fffdf7;
    background: var(--chalk-soft);
    box-shadow: 0 6px 0 #4f7748;
}

.button.ghost {
    color: var(--ink);
    background: #fffdf7;
    border-color: var(--line);
}

.button:disabled {
    cursor: wait;
    opacity: 0.62;
}

.compact {
    gap: 0.55rem;
}

.stat-row,
.history-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.stat-row strong {
    font-size: 1.55rem;
}

.text-button {
    padding: 0;
    color: var(--chalk);
    background: transparent;
    border: 0;
    font-size: 0.86rem;
    font-weight: 900;
}

.history-list {
    display: grid;
    max-height: 170px;
    gap: 0.45rem;
    overflow: auto;
    margin: 0;
    padding-left: 1.35rem;
    color: var(--muted);
    line-height: 1.45;
}

.history-list strong {
    color: var(--ink);
}

.history-win::marker,
.history-win strong {
    color: #1f6b3f;
}

.history-lose::marker,
.history-lose strong {
    color: #8a3529;
}

@keyframes result-sweep {
    to {
        transform: translateX(100%);
    }
}

@media (max-width: 880px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .site-header::before {
        height: 120px;
    }

    .site-nav {
        width: 100%;
        overflow-x: auto;
    }

    .tool-header,
    .tool-layout {
        grid-template-columns: 1fr;
    }

    .tool-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .result-card {
        width: 100%;
    }

    .control-panel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .panel-card:first-child,
    .panel-card:last-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 560px) {
    .control-panel {
        grid-template-columns: 1fr;
    }

    .panel-card:first-child,
    .panel-card:last-child {
        grid-column: auto;
    }

    #rouletteCanvas {
        min-height: 360px;
    }
}
