/* 오늘의 상소: the king's day before a flat 일월오봉도. Cobalt sky, a white moon on the left and a red sun
   on the right, teal peaks, red-trunked pines and white-crested waves, all with ink outlines and no glow.
   Plates, the card and the buttons use the site's white-with-ink style; peony pink marks what is mine. */
.sangso-page {
    --sky: #2F51C2;
    --sun: #F05A3C;
    --wave: #A8BEFF;
    --danger: #C8331C;
    --card-w: min(232px, 62vw);
}

.sangso-page .site-main {
    position: relative;
    overflow: hidden;
    background: var(--sky);
}

.screen[hidden] { display: none; }
.column { position: relative; max-width: 600px; margin: 0 auto; padding: 0 16px; }
.tabular { font-variant-numeric: tabular-nums; }
.sangso-page :focus-visible { outline: 3px solid var(--paper); outline-offset: 2px; }
.sangso-page .plate :focus-visible, .sangso-page .card:focus-visible { outline-color: var(--ink); }

.plate {
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 18px;
    padding: 14px 16px 16px;
}
.plate h2 { margin: 0; font-size: 15px; font-weight: 900; letter-spacing: -0.02em; }
.is-lifted { border-radius: 20px; box-shadow: 0 6px 0 var(--ink); }

.chips { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    display: inline-block;
    margin: 0;
    background: var(--paper);
    border: 1.5px solid var(--ink);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 12.5px;
    font-weight: 900;
    line-height: 1.5;
}
.chip.is-ink { background: var(--ink); color: var(--paper); }

/* Moon and sun */
.orb { position: absolute; z-index: 0; box-sizing: border-box; border: 3px solid var(--ink); border-radius: 50%; pointer-events: none; }
.orb.moon { background: var(--paper); }
.orb.sun { background: var(--sun); }

/* Gauges: an icon that fills from the bottom. */
.gauges { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gauge { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.gauge-icon { display: block; width: 38px; height: 38px; overflow: visible; }
.gauge-fill { transition: transform 0.45s ease; }
.gauge-name { font-size: 11.5px; font-weight: 800; line-height: 1.25; white-space: nowrap; }
.gauge-name b { font-variant-numeric: tabular-nums; }
.gauge.is-out .gauge-name b { color: var(--danger); }
.gauge-dot { height: 14px; display: flex; align-items: center; justify-content: center; }

.dot { display: inline-block; flex: none; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dot.is-big { width: 12px; height: 12px; }

/* People: a coloured disc with a hat, never a face. */
.disc {
    flex: none;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    border: 2.5px solid var(--ink);
    border-radius: 50%;
    background: var(--disc, var(--paper));
}
.disc .hat { display: block; width: 74%; height: 74%; }

/* ---------- 즉위 전 ---------- */
.hero { position: relative; height: 300px; }
.hero-art { position: absolute; left: 50%; bottom: 0; width: 1920px; height: 330px; margin-left: -960px; display: block; }
.hero .moon { width: 60px; height: 60px; left: calc(50% - min(42vw, 330px)); top: 50px; }
.hero .sun { width: 76px; height: 76px; right: calc(50% - min(42vw, 330px)); top: 46px; }

.intro-body { margin-top: -64px; display: flex; flex-direction: column; gap: 14px; padding-bottom: 32px; }
.title-plate { padding: 16px 16px 18px; }
.title-plate h1 { margin: 12px 0 0; font-size: 46px; font-weight: 900; letter-spacing: -0.055em; line-height: 1.05; }
.lead { margin: 10px 0 0; font-size: 15.5px; font-weight: 700; line-height: 1.6; }
.title-plate .gauges { margin-top: 14px; padding-top: 12px; border-top: 1.5px dashed var(--ink); }
.done-note { margin: 12px 0 0; padding: 10px 12px; border: 1.5px solid var(--ink); border-radius: 12px; background: var(--peony); font-size: 14.5px; font-weight: 800; line-height: 1.5; }

.mood { background: var(--peony); border: 2px solid var(--ink); border-radius: 18px; padding: 14px 16px; }
.mood h2 { margin: 0; }
.mood-text { margin: 8px 0 0; font-size: 20px; font-weight: 900; letter-spacing: -0.03em; line-height: 1.35; }
.mood-note { margin: 4px 0 0; display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 800; }
.mood-note svg { width: 16px; height: 16px; flex: none; }

.cast h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cast h2 span { font-size: 12px; font-weight: 800; color: var(--muted); }
.cast-list { margin: 12px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.cast-list li { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.cast-list .disc { width: 50px; height: 50px; }
.cast-list span { font-size: 11.5px; font-weight: 800; white-space: nowrap; }

.throne {
    width: 100%;
    height: 62px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: var(--ink);
    color: var(--paper);
    font-size: 20px;
    font-weight: 900;
    letter-spacing: -0.02em;
    cursor: pointer;
    box-shadow: 0 5px 0 rgba(22, 22, 22, 0.35);
}
.throne.is-line { height: 52px; background: var(--paper); color: var(--ink); font-size: 16px; box-shadow: none; }
.throne:disabled { opacity: 0.5; cursor: default; }
.start { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.on-sky { margin: 0; text-align: center; color: var(--paper); font-size: 12.5px; font-weight: 800; line-height: 1.55; }
.on-sky .btn { margin-top: 8px; }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 40px; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 800; }
.bar-track { height: 12px; box-sizing: border-box; border: 1.5px solid var(--ink); border-radius: 6px; background: var(--ground); overflow: hidden; }
.bar-track i { display: block; height: 100%; background: var(--ink); }
.bar-row.is-mine .bar-track i { background: var(--peony); }
.bar-row b { text-align: right; font-variant-numeric: tabular-nums; }
.yesterday-line { margin: 6px 0 12px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.yesterday-sub { margin: 0 0 8px; font-size: 13px; font-weight: 900; }

.how ol { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; font-size: 14px; line-height: 1.55; }
.how li { display: flex; gap: 10px; }
.how li b {
    flex: none;
    width: 24px;
    height: 24px;
    box-sizing: border-box;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--peony);
    border: 1.5px solid var(--ink);
    font-size: 12px;
}

/* ---------- 상소 ---------- */
.play-body { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; padding-bottom: 28px; }
.play-body > * { position: relative; z-index: 1; }
.play-body > .stage { z-index: 0; }

.hud { background: var(--paper); border: 2px solid var(--ink); border-radius: 18px; padding: 6px 10px 8px; }
.hud .gauge-icon { width: 40px; height: 40px; }
.hud .gauge.is-hit .gauge-icon { animation: gauge-hit 0.45s ease; }
@keyframes gauge-hit { 40% { transform: scale(1.14); } }

.year-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.year-row .chip { font-size: 13px; padding: 3px 12px; }
.year-row .chip.is-ink { font-size: 14.5px; padding: 3px 14px; }

.petition { padding: 12px 14px 14px; }
.speaker { margin: 0; display: flex; align-items: center; gap: 8px; }
.speaker .disc { width: 30px; height: 30px; border-width: 2px; }
.speaker b { font-size: 14.5px; font-weight: 900; }
.speaker span { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.petition-text { margin: 8px 0 0; min-height: 3.24em; font-size: 16px; font-weight: 700; line-height: 1.62; letter-spacing: -0.02em; }

.stage { height: 300px; }
.ridge { position: absolute; z-index: 0; left: 50%; bottom: -36px; width: 1920px; height: 420px; margin-left: -960px; display: block; pointer-events: none; }
/* Moon and sun in front of the mountains, the cards in front of both. */
.stage .orb { z-index: 1; }
.deck-back, .card { z-index: 2; }
.stage .moon { width: 42px; height: 42px; left: calc(50% - min(47vw, 540px)); top: 46px; }
.stage .sun { width: 46px; height: 46px; right: calc(50% - min(47vw, 540px)); top: 132px; }

.deck-back, .card {
    position: absolute;
    left: 50%;
    width: var(--card-w);
    aspect-ratio: 230 / 262;
    margin-left: calc(var(--card-w) / -2);
    box-sizing: border-box;
    border: 2.5px solid var(--ink);
    border-radius: 24px;
    box-shadow: 0 7px 0 var(--ink);
}
.deck-back {
    top: 18px;
    transform: translateX(-12px) rotate(-4deg);
    background-color: var(--peony);
    background-image: radial-gradient(var(--paper) 2px, transparent 2.5px);
    background-size: 18px 18px;
}
.card {
    top: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background-color: var(--paper);
    background-image: linear-gradient(#EEF0F5 2px, transparent 2px), linear-gradient(90deg, #EEF0F5 2px, transparent 2px);
    background-size: 24px 24px;
    background-position: -1px -1px;
    transform: translateX(var(--dx, 0px)) rotate(var(--rot, 0deg));
    transform-origin: 50% 120%;
    transition: transform 0.22s ease, opacity 0.22s ease;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
}
.card.is-dragging { transition: none; cursor: grabbing; }
.card.is-yes { --dx: 22px; --rot: 7deg; }
.card.is-no { --dx: -22px; --rot: -7deg; }
.card.is-dragging.is-yes, .card.is-dragging.is-no { --dx: initial; --rot: initial; }
.card.is-gone { opacity: 0; transition: transform 0.28s ease-in, opacity 0.28s ease-in; }
.card.is-gone.is-yes { transform: translateX(150%) rotate(26deg); }
.card.is-gone.is-no { transform: translateX(-150%) rotate(-26deg); }
.card.is-new { animation: card-in 0.24s ease-out; }
@keyframes card-in { from { transform: translateY(14px) scale(0.96); } }
.card-top { margin: 0; align-self: stretch; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; min-height: 42px; }
.card.is-no .card-top { flex-direction: row-reverse; }
.card-name { flex: none; }
.card-say {
    visibility: hidden;
    max-width: 62%;
    background: var(--ink);
    color: var(--paper);
    border-radius: 10px;
    padding: 5px 10px;
    font-size: 14px;
    font-weight: 900;
    line-height: 1.3;
    text-align: right;
    word-break: keep-all;
}
.card.is-no .card-say { text-align: left; }
.card.is-yes .card-say, .card.is-no .card-say { visibility: visible; }
.card .disc.is-big { width: 58%; aspect-ratio: 1; height: auto; border-width: 3px; }
.card-role { margin: 0; font-size: 12.5px; font-weight: 800; color: var(--muted); text-align: center; }

.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
/* The waves run under the buttons, across the whole screen and down to the footer. */
.choices::before {
    content: "";
    position: absolute;
    z-index: -1;
    left: 50%;
    top: 18px;
    width: 100vw;
    height: 2000px;
    margin-left: -50vw;
    background: url("/sangso/art/waves.svg") repeat-x 0 0 / 80px 600px, linear-gradient(transparent 590px, var(--wave) 590px);
}
.choice {
    min-height: 64px;
    padding: 8px 12px;
    box-sizing: border-box;
    border: 2px solid var(--ink);
    border-radius: 18px;
    background: var(--paper);
    color: var(--ink);
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 5px;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--ink);
}
.choice.is-right { text-align: right; align-items: flex-end; }
.choice.is-on { background: var(--ink); color: var(--paper); box-shadow: 0 4px 0 rgba(22, 22, 22, 0.35); }
.choice:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.choice:disabled { cursor: default; }
.choice-say { display: flex; align-items: center; gap: 5px; font-size: 15px; font-weight: 900; letter-spacing: -0.02em; line-height: 1.3; }
.choice-say svg { width: 14px; height: 14px; flex: none; }
.choice-dots { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12px; font-weight: 800; }
.choice-dots span { display: inline-flex; align-items: center; gap: 4px; }
.choice-dots .is-none { opacity: 0.7; }

.hint {
    margin: 2px 0 0;
    align-self: center;
    background: var(--paper);
    border: 1.5px solid var(--ink);
    border-radius: 999px;
    padding: 3px 12px;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
}
.status { margin: 0; text-align: center; font-size: 14px; font-weight: 800; }
.status:empty { display: none; }
.status-box { background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 10px 12px; }
.status .btn { margin-top: 8px; min-height: 42px; }

/* ---------- 물러난 뒤 ---------- */
.end-body { display: flex; flex-direction: column; gap: 14px; padding-top: 18px; padding-bottom: 8px; }
.end .sun { width: 48px; height: 48px; right: calc(50% - min(48vw, 330px)); top: 28px; }
.result { padding: 16px 16px 18px; }
.result-label { margin: 0; font-size: 13px; font-weight: 900; color: var(--muted); }
.result h1 { margin: 2px 0 0; font-size: 48px; font-weight: 900; letter-spacing: -0.06em; line-height: 1.08; overflow-wrap: anywhere; }
.result-line { margin: 10px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.years { background: var(--ink); color: var(--paper); border-radius: 10px; padding: 4px 12px; font-size: 22px; font-weight: 900; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.ending-chip { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--ink); border-radius: 10px; padding: 2px 10px 2px 6px; font-size: 18px; font-weight: 900; }
.ending-chip .gauge-icon { width: 26px; height: 26px; }
.result-text { margin: 14px 0 0; padding-top: 12px; border-top: 1.5px dashed var(--ink); font-size: 15.5px; font-weight: 700; line-height: 1.7; }
.result .gauges { margin-top: 14px; padding: 10px 4px 8px; border: 1.5px solid var(--ink); border-radius: 14px; background: var(--ground); }
.result .gauge-icon { width: 36px; height: 36px; }

.stats { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--paper); border: 2px solid var(--ink); border-radius: 16px; padding: 10px 12px; }
.stat dt { font-size: 12px; font-weight: 800; color: var(--muted); }
.stat dd { margin: 2px 0 0; font-size: 22px; font-weight: 900; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

.dist-bars { margin-top: 12px; height: 118px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; align-items: end; border-bottom: 2px solid var(--ink); }
.dist-bars div { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
.dist-bars i { display: block; width: 100%; box-sizing: border-box; border: 1.5px solid var(--ink); border-bottom: 0; border-radius: 5px 5px 0 0; background: var(--ink); }
.dist-bars .is-mine i { background: var(--peony); }
.dist-bars em { font-style: normal; font-size: 11px; font-weight: 900; background: var(--ink); color: var(--paper); border-radius: 999px; padding: 0 6px; }
.dist-labels { margin-top: 5px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dist-labels span { text-align: center; font-size: 10.5px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.why .bars { margin-top: 10px; }

.end-actions { display: flex; flex-direction: column; gap: 12px; }
.end-actions .throne { height: 58px; font-size: 18px; }
.toast { margin: 0; text-align: center; color: var(--paper); font-size: 13px; font-weight: 800; }
.end-art { position: relative; height: 190px; margin-top: 18px; }
.end-art img { position: absolute; left: 50%; bottom: 20px; width: 1920px; height: 170px; margin-left: -960px; display: block; }
.end-art::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 44px;
    background: url("/sangso/art/waves.svg") repeat-x 0 0 / 80px 600px;
}

@media (max-width: 640px) {
    .hero { height: 250px; }
    .hero-art { left: 0; width: 100%; height: auto; margin-left: 0; }
    .hero .moon { top: 26px; width: 52px; height: 52px; }
    .hero .sun { top: 22px; width: 66px; height: 66px; }
    .title-plate h1 { font-size: 42px; }
}

/* Phones: the reign fills the screen under the header and keeps its last 76px for the AdSense bottom
   anchor, so the two answers never sit under it. The stage takes what height is left and the card
   shrinks to fit it (a long petition makes the card smaller, not the buttons lower). */
@media (max-width: 640px) {
    .play-body {
        height: calc(100vh - 48px);
        height: calc(100svh - 48px);
        box-sizing: border-box;
        padding-bottom: 76px;
    }
    .stage { flex: 1 1 0; min-height: 160px; height: auto; container-type: size; }
    .deck-back, .card {
        left: 0;
        right: 0;
        width: min(var(--card-w), calc((100cqh - 24px) * 230 / 262));
        margin: 0 auto;
    }
}

/* Phones with the browser's bars showing: everything tighter. */
@media (max-width: 640px) and (max-height: 760px) {
    .sangso-page { --card-w: 188px; }
    .play-body { gap: 8px; padding-top: 8px; }
    .hud { padding: 3px 8px 5px; }
    .hud .gauge-icon { width: 34px; height: 34px; }
    .hud .gauge-dot { height: 11px; }
    .year-row .chip { padding: 1px 10px; font-size: 12px; }
    .year-row .chip.is-ink { padding: 1px 12px; font-size: 13px; }
    .petition { padding: 9px 12px 11px; }
    .speaker .disc { width: 26px; height: 26px; }
    .petition-text { margin-top: 5px; font-size: 15px; line-height: 1.55; }
    .stage .moon { top: 30px; }
    .stage .sun { top: 104px; }
    .card { top: 6px; padding: 10px; border-radius: 20px; }
    .deck-back { top: 14px; border-radius: 20px; }
    .card-top { min-height: 32px; }
    .card-say { font-size: 13px; padding: 4px 8px; }
    .card-role { font-size: 11.5px; }
    .choice { min-height: 54px; padding: 6px 10px; border-radius: 16px; }
    .choice-say { font-size: 14px; }
    .hint { display: none; }
}

@media (min-width: 641px) {
    .sangso-page { --card-w: 252px; }
    .hero { height: 330px; }
    .hud .gauge-icon { width: 46px; height: 46px; }
    .gauge-name { font-size: 12.5px; }
    .petition { padding: 16px 18px 18px; }
    .petition-text { font-size: 18px; }
    .stage { height: 330px; }
    .choice { min-height: 70px; padding: 10px 16px; }
    .choice-say { font-size: 16.5px; }
    .hint { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
    .card, .gauge-fill { transition: none; }
    .card.is-new, .hud .gauge.is-hit .gauge-icon { animation: none; }
}
