/* 슬롭 다이스: 밤의 게임 테이블. 나무 테두리에 초록 펠트, 토토는 분홍, 모찌는 노랑. */
:root {
  color-scheme: dark;
  --bg: #120f16;
  --bg-2: #1b1620;
  --glass: rgba(255, 255, 255, 0.045);
  --glass-2: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.18);
  --text: #f7f1ea;
  --muted: #b3a8a0;
  --faint: #776d68;
  --lime: #d4ff00;
  --lime-ink: #1a2000;
  --p0: #ff7aa8;
  --p0-soft: rgba(255, 122, 168, 0.13);
  --p1: #ffd23f;
  --p1-soft: rgba(255, 210, 63, 0.12);
  --ivory: #fbf6ec;
  --pip: #23161c;
  --font-display: 'Jua', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --font-ui: 'Gowun Dodum', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(700px 420px at 12% -6%, rgba(255, 122, 168, 0.16), transparent 65%),
    radial-gradient(700px 420px at 92% -4%, rgba(255, 210, 63, 0.12), transparent 65%),
    radial-gradient(1000px 600px at 50% 120%, rgba(212, 255, 0, 0.07), transparent 60%),
    radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1.4px) 0 0 / 26px 26px,
    var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

button:focus-visible,
[role='button']:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

h1,
h2,
p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

/* ---------- 레이아웃 ---------- */

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  display: grid;
  gap: 16px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  background: linear-gradient(160deg, #fff, var(--ivory) 55%, #e8dcc6);
  box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.6), inset 0 -2px 0 rgba(0, 0, 0, 0.12);
  transform: rotate(-10deg);
  position: relative;
}

.logo i {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff3d8b;
}

.logo i:nth-child(1) { left: 6px; top: 6px; }
.logo i:nth-child(2) { left: 13.5px; top: 13.5px; }
.logo i:nth-child(3) { right: 6px; bottom: 6px; }

h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: linear-gradient(90deg, var(--p0), #fff 50%, var(--p1));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.round-chip {
  font-family: var(--font-display);
  font-size: 18px;
  padding: 3px 12px 2px;
  border-radius: 999px;
  background: var(--glass-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.round-chip small {
  font-size: 13px;
  color: var(--muted);
}

.top-actions {
  display: flex;
  gap: 8px;
}

.ghost {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--glass);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.ghost:hover {
  background: var(--glass-2);
  border-color: rgba(255, 255, 255, 0.3);
}

.icon-btn[aria-pressed='false'] {
  color: var(--faint);
}

.primary {
  appearance: none;
  border: 0;
  border-radius: 16px;
  padding: 14px 22px;
  background: var(--lime);
  color: var(--lime-ink);
  font-family: var(--font-display);
  font-size: 19px;
  cursor: pointer;
  box-shadow: 0 6px 0 #8aa600, 0 14px 30px -10px rgba(212, 255, 0, 0.55);
  transition: transform 0.1s, box-shadow 0.1s, filter 0.15s;
}

.primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.primary:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #8aa600, 0 8px 20px -10px rgba(212, 255, 0, 0.5);
}

.primary:disabled {
  background: #3a3530;
  color: var(--faint);
  box-shadow: 0 6px 0 #262220;
  cursor: default;
}

/* ---------- 플레이어 ---------- */

.versus {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.player {
  --pc: var(--p0);
  --pc-soft: var(--p0-soft);
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px 12px 12px;
  border-radius: 24px;
  background: linear-gradient(140deg, var(--glass-2), var(--glass));
  border: 1px solid var(--line);
  transition: border-color 0.25s, box-shadow 0.25s, opacity 0.25s, transform 0.25s;
  opacity: 0.62;
}

.player.p1 {
  --pc: var(--p1);
  --pc-soft: var(--p1-soft);
  flex-direction: row-reverse;
  padding: 12px 12px 12px 18px;
  text-align: right;
}

.player.is-active {
  opacity: 1;
  border-color: var(--pc);
  background: linear-gradient(140deg, var(--pc-soft), var(--glass));
  box-shadow: 0 0 0 4px var(--pc-soft), 0 18px 40px -18px var(--pc);
}

.avatar {
  position: relative;
  width: 86px;
  height: 86px;
  flex: none;
}

.avatar .char {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.player.is-active .avatar {
  animation: bob 1.2s ease-in-out infinite;
}

.player.is-hop .avatar {
  animation: hop 0.6s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.player:not(.is-active) .char {
  filter: saturate(0.6);
}

.who {
  min-width: 0;
  flex: 1;
}

.pname {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--pc);
}

.pscore {
  font-family: var(--font-display);
  line-height: 1;
}

.pscore strong {
  font-weight: 400;
  font-size: 42px;
}

.pscore small {
  font-size: 16px;
  color: var(--muted);
  margin-left: 2px;
}

.pmeta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.turn-tag {
  position: absolute;
  top: -10px;
  right: 18px;
  padding: 2px 10px 1px;
  border-radius: 999px;
  background: var(--pc);
  color: #1d1218;
  font-family: var(--font-display);
  font-size: 14px;
  opacity: 0;
  transform: translateY(4px) scale(0.9);
  transition: opacity 0.2s, transform 0.25s;
}

.player.p1 .turn-tag {
  right: auto;
  left: 18px;
}

.player.is-active .turn-tag {
  opacity: 1;
  transform: none;
}

.vs {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--faint);
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-2);
}

/* 말풍선 */
.bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 4px);
  z-index: 3;
  padding: 4px 10px 3px;
  border-radius: 12px;
  background: #fff;
  color: #2a1a22;
  font-family: var(--font-display);
  font-size: 14px;
  white-space: nowrap;
  box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, 6px) scale(0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: #fff;
}

.bubble.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

/* ---------- 캐릭터 표정 ---------- */

.char .eyes-h,
.char .eyes-s,
.char .mouth-h,
.char .mouth-s {
  display: none;
}

.char.is-happy .eyes-n,
.char.is-happy .mouth-n,
.char.is-sad .eyes-n,
.char.is-sad .mouth-n {
  display: none;
}

.char.is-happy .eyes-h,
.char.is-happy .mouth-h,
.char.is-sad .eyes-s,
.char.is-sad .mouth-s {
  display: inline;
}

.char {
  transform-origin: 50% 95%;
  animation: breathe 2.8s ease-in-out infinite;
}

.char .eyes-n {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 4.6s infinite;
}

.char-mochi .eyes-n {
  animation-delay: 1.7s;
}

.char .ear {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

.char .ear-l {
  animation: ear-l 3.4s ease-in-out infinite;
}

.char.is-happy .ear-l {
  animation: ear-flop 0.5s ease-in-out infinite alternate;
}

.char.is-happy .ear-r {
  animation: ear-flop 0.5s ease-in-out infinite alternate-reverse;
}

.char.is-sad .ear {
  transform: rotate(-30deg);
}

.char.is-sad .ear-r {
  transform: rotate(30deg);
}

.char .wing {
  transform-box: fill-box;
}

.char .wing-l {
  transform-origin: 100% 30%;
}

.char .wing-r {
  transform-origin: 0 30%;
}

.char.is-happy .wing-l {
  animation: flap-l 0.22s ease-in-out infinite alternate;
}

.char.is-happy .wing-r {
  animation: flap-r 0.22s ease-in-out infinite alternate;
}

.char .tuft {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: tuft 2.2s ease-in-out infinite;
}

.char .tear {
  animation: tear 1.2s ease-in infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.03, 0.97); }
}

@keyframes blink {
  0%, 93%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.1); }
}

@keyframes ear-l {
  0%, 70%, 100% { transform: rotate(0); }
  80% { transform: rotate(-12deg); }
  90% { transform: rotate(4deg); }
}

@keyframes ear-flop {
  from { transform: rotate(-10deg); }
  to { transform: rotate(10deg); }
}

@keyframes flap-l {
  from { transform: rotate(0); }
  to { transform: rotate(32deg); }
}

@keyframes flap-r {
  from { transform: rotate(0); }
  to { transform: rotate(-32deg); }
}

@keyframes tuft {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(8deg); }
}

@keyframes tear {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(10px); opacity: 0; }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes hop {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-16px) scale(0.96, 1.06); }
  60% { transform: translateY(0) scale(1.08, 0.92); }
  100% { transform: translateY(0) scale(1); }
}

/* ---------- 본문 2단 ---------- */

.play {
  display: grid;
  gap: 16px;
  align-items: start;
}

@media (min-width: 960px) {
  .play {
    grid-template-columns: minmax(0, 1.5fr) minmax(330px, 1fr);
    gap: 20px;
  }

  .sheet-card {
    position: sticky;
    top: 16px;
  }
}

/* ---------- 판 ---------- */

.table {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.rim {
  position: relative;
  padding: 14px;
  border-radius: 28px;
  background:
    repeating-linear-gradient(100deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 9px),
    linear-gradient(150deg, #7a4826, #4a2712 45%, #6a3a1c 75%, #3a1d0c);
  box-shadow:
    0 40px 70px -30px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 230, 190, 0.25),
    inset 0 -3px 0 rgba(0, 0, 0, 0.35);
}

.rim::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 22px;
  border: 1.5px dashed rgba(255, 226, 122, 0.35);
  pointer-events: none;
}

.board {
  position: relative;
  aspect-ratio: 600 / 360;
  border-radius: 16px;
  box-shadow: 0 0 0 3px #2a1508, 0 2px 0 4px rgba(255, 230, 190, 0.12);
  user-select: none;
  -webkit-user-select: none;
}

.stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 600px;
  height: 360px;
  transform-origin: 0 0;
}

.felt {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 80% at 45% 40%, #2a8a64 0%, #186446 45%, #0c3a2a 100%);
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.6), inset 0 0 0 2px rgba(0, 0, 0, 0.4);
}

.felt::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(rgba(255, 255, 255, 0.05) 0.8px, transparent 1px) 0 0 / 5px 5px,
    radial-gradient(rgba(0, 0, 0, 0.12) 0.8px, transparent 1px) 2px 3px / 7px 7px;
}

.felt::after {
  content: 'SLOP DICE';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 230px;
  height: 230px;
  margin: -115px 0 0 -115px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.02), inset 0 0 0 10px rgba(255, 255, 255, 0.02);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 40px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.06);
}

.shadows,
.dice-layer {
  position: absolute;
  inset: 0;
}

.shadows {
  z-index: 1;
  pointer-events: none;
}

.die-shadow {
  position: absolute;
  left: 0;
  top: 0;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: rgba(0, 10, 5, 0.75);
  filter: blur(5px);
}

.die-shadow.is-off {
  display: none;
}

.dice-layer {
  z-index: 2;
  perspective: 1100px;
  perspective-origin: 50% 45%;
  transform-style: preserve-3d;
}

.die3d {
  position: absolute;
  left: 0;
  top: 0;
  width: 54px;
  height: 54px;
  transform-style: preserve-3d;
  cursor: pointer;
  outline-offset: 6px;
}

.die3d.is-off {
  visibility: hidden;
  pointer-events: none;
}

.die3d.is-locked {
  cursor: default;
}

/* 보관할 수 있을 때 바닥에 라임 고리 */
.die3d::before {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 16px;
  border: 2.5px solid var(--lime);
  box-shadow: 0 0 18px rgba(212, 255, 0, 0.5);
  opacity: 0;
  transition: opacity 0.15s;
}

.die3d:not(.is-locked):hover::before,
.die3d:focus-visible::before {
  opacity: 1;
}

.pop,
.cube {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.pop {
  transition: transform 0.15s;
}

.die3d:not(.is-locked):hover .pop {
  transform: translateZ(10px);
}

.pop.is-pop {
  animation: die-pop 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@keyframes die-pop {
  0% { transform: translateZ(60px) scale(0.6); }
  100% { transform: none; }
}

.side {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: radial-gradient(circle at 30% 25%, #fff, var(--ivory) 55%, #ece2d0);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06), inset 0 -3px 6px rgba(120, 90, 60, 0.18);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  padding: 7px;
}

.side::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #1c0f16;
  opacity: var(--shade, 0);
  pointer-events: none;
}

.s0 { transform: rotateY(90deg) translateZ(27px); }
.s1 { transform: rotateY(-90deg) translateZ(27px); }
.s2 { transform: rotateX(-90deg) translateZ(27px); }
.s3 { transform: rotateX(90deg) translateZ(27px); }
.s4 { transform: translateZ(27px); }
.s5 { transform: rotateY(180deg) translateZ(27px); }

/* 둥근 모서리 틈으로 속이 비쳐 보이지 않게 가운데를 막는 판 세 장 */
.core {
  position: absolute;
  inset: 3px;
  border-radius: 6px;
  background: #e6dac4;
}

.cx { transform: rotateY(90deg); }
.cy { transform: rotateX(90deg); }

.pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.pip.on {
  background: radial-gradient(circle at 35% 30%, #5a4250, var(--pip) 70%);
  box-shadow: inset 0 1.5px 1.5px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.8);
}

.v1 .pip.on,
.v4 .pip.on {
  background: radial-gradient(circle at 35% 30%, #ff8cba, #ff2d7f 60%, #b3105a);
}

.v1 .pip.on {
  transform: scale(1.6);
}

/* 판 위 안내, 차례 배너 */
.board-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 26px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 0 24px rgba(212, 255, 0, 0.35);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}

.board-hint::after {
  content: '';
  position: absolute;
  right: -66px;
  top: 34px;
  width: 52px;
  height: 52px;
  border-right: 3px dashed rgba(212, 255, 0, 0.7);
  border-bottom: 3px dashed rgba(212, 255, 0, 0.7);
  border-bottom-right-radius: 40px;
  transform: rotate(-10deg);
}

.board-hint.show {
  opacity: 1;
  animation: hint-bob 1.6s ease-in-out infinite;
}

@keyframes hint-bob {
  0%, 100% { transform: translate(-50%, -50%); }
  50% { transform: translate(-50%, -58%); }
}

.banner {
  position: absolute;
  left: 50%;
  top: 22px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 22px 6px 8px;
  border-radius: 999px;
  background: #fff;
  color: #2a1a22;
  box-shadow: 0 16px 30px -12px rgba(0, 0, 0, 0.7);
  font-family: var(--font-display);
  font-size: 24px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -20px) scale(0.8);
}

.banner.p0 b { color: #e8467e; font-weight: 400; }
.banner.p1 b { color: #d99a00; font-weight: 400; }

.banner-char .char {
  width: 52px;
  height: 52px;
  display: block;
}

.banner.show {
  animation: banner 1.6s cubic-bezier(0.3, 1.4, 0.5, 1) forwards;
}

@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -20px) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -12px) scale(0.95); }
}

/* ---------- 컵 ---------- */

.cup {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  width: 92px;
  height: 103px;
  transform-origin: 50% 55%;
  cursor: grab;
  touch-action: none;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.45));
  transition: filter 0.2s;
}

.cup svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.cup::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 110px;
  height: 34px;
  margin-left: -55px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(212, 255, 0, 0.55), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.cup.is-ready::before {
  opacity: 1;
  animation: glow 1.6s ease-in-out infinite;
}

.cup.is-ready svg {
  animation: cup-bob 1.6s ease-in-out infinite;
}

.cup.is-held {
  cursor: grabbing;
  filter: drop-shadow(0 26px 18px rgba(0, 0, 0, 0.5));
}

.cup.is-held::before {
  opacity: 0;
}

.cup.is-held svg {
  animation: none;
}

.cup.is-rattle svg {
  animation: rattle 0.14s linear;
}

.cup.is-no svg {
  animation: nope 0.4s ease-in-out;
}

.cup.is-pouring {
  transition: transform 0.2s ease-out, filter 0.2s;
}

.cup.is-returning {
  transition: transform 0.6s cubic-bezier(0.3, 1.35, 0.5, 1), filter 0.3s;
}

.cup[aria-disabled='true']:not(.is-held) {
  cursor: default;
}

.cup-count {
  position: absolute;
  top: -6px;
  right: -2px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  background: var(--lime);
  color: var(--lime-ink);
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 25px;
  text-align: center;
  box-shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.5);
}

@keyframes glow {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
}

@keyframes cup-bob {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-4px) rotate(-3deg); }
}

@keyframes rattle {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 1px) rotate(-4deg); }
  50% { transform: translate(3px, -1px) rotate(4deg); }
  75% { transform: translate(-2px, 0) rotate(-2deg); }
  100% { transform: translate(0, 0); }
}

@keyframes nope {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-10deg); }
  40% { transform: rotate(9deg); }
  60% { transform: rotate(-6deg); }
  80% { transform: rotate(3deg); }
}

/* ---------- 보관함과 굴림 ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.rack-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 16px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--line);
}

.rack-label {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--muted);
  writing-mode: horizontal-tb;
}

.rack {
  display: flex;
  gap: 8px;
}

.slot {
  appearance: none;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.2);
  display: grid;
  place-items: center;
  cursor: default;
}

.slot-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--faint);
}

.slot.is-filled {
  border: 0;
  background: none;
  cursor: pointer;
}

.slot.is-filled:disabled {
  cursor: default;
}

.slot.is-filled .flat-die {
  box-shadow: 0 0 0 2.5px var(--lime), 0 0 16px rgba(212, 255, 0, 0.4), 0 6px 0 #c9bca4;
}

.slot.is-filled:not(:disabled):hover .flat-die {
  transform: translateY(-3px);
}

.flat-die {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 25%, #fff, var(--ivory) 55%, #ece2d0);
  box-shadow: 0 5px 0 #c9bca4, 0 10px 16px -8px rgba(0, 0, 0, 0.7);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  padding: 7px;
  transition: transform 0.15s;
}

.flat-die.is-in {
  animation: drop-in 0.3s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@keyframes drop-in {
  from { transform: translateY(-24px) scale(0.7); }
  to { transform: none; }
}

.flat-die.mini {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 6px;
  padding: 3px;
  box-shadow: 0 2px 0 #c9bca4;
}

.flat-die.mini .pip {
  width: 4px;
  height: 4px;
}

.flat-die.mini .pip.on {
  box-shadow: none;
}

.flat-die.mini.v1 .pip.on {
  transform: scale(1.4);
}

.roll-box {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.rolls-left {
  display: grid;
  justify-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.rolls-text strong {
  font-family: var(--font-mono);
  color: var(--text);
}

.dots {
  display: flex;
  gap: 6px;
}

.dots i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  transition: background 0.2s, box-shadow 0.2s;
}

.dots i.on {
  background: var(--lime);
  box-shadow: 0 0 10px rgba(212, 255, 0, 0.6);
}

.roll {
  min-width: 150px;
}

.hint {
  min-height: 1.45em;
  color: var(--text);
  font-size: 15px;
}

.keys {
  font-size: 12.5px;
  color: var(--faint);
  margin-top: -8px;
}

.keys b {
  color: var(--muted);
}

kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  color: var(--muted);
}

/* ---------- 점수표 ---------- */

.sheet-card {
  border-radius: 24px;
  padding: 8px 10px 12px;
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--line);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
  min-width: 0;
}

.sheet {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.sheet .cat-col {
  width: auto;
}

.sheet .pcol {
  width: 27%;
}

.sheet thead th {
  padding: 8px 4px 10px;
  font-weight: 400;
  text-align: left;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.sheet thead .pcol {
  text-align: center;
  font-size: 17px;
}

.sheet thead .p0 { color: var(--p0); }
.sheet thead .p1 { color: var(--p1); }

.mini-char {
  display: block;
  width: 38px;
  height: 38px;
  margin: 0 auto 2px;
}

.mini-char .char {
  width: 100%;
  height: 100%;
  overflow: visible;
  animation: none;
}

/* 차례인 사람 열을 은은하게 칠한다 */
body[data-turn='0'] .sheet .p0,
body[data-turn='1'] .sheet .p1 {
  background: var(--pc-soft);
}

.sheet .p0 { --pc: var(--p0); --pc-soft: var(--p0-soft); }
.sheet .p1 { --pc: var(--p1); --pc-soft: var(--p1-soft); }

body[data-turn='0'] .sheet thead .p0,
body[data-turn='1'] .sheet thead .p1 {
  border-radius: 14px 14px 0 0;
}

.sheet tr.section th {
  padding: 12px 6px 4px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 15px;
  text-align: left;
  color: var(--text);
}

.sheet tr.section small {
  font-family: var(--font-ui);
  font-size: 11.5px;
  color: var(--faint);
  margin-left: 6px;
}

.sheet tr.row th {
  padding: 4px 6px;
  text-align: left;
  font-weight: 400;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sheet td {
  padding: 3px 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  text-align: center;
}

.cat {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cat-text {
  display: grid;
  min-width: 0;
}

.cat-name {
  font-weight: 700;
  font-size: 14.5px;
  white-space: nowrap;
}

.cat-rule {
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet tr.is-open-row .cat-name {
  color: #fff;
}

.cell {
  appearance: none;
  width: 100%;
  height: 38px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  background: none;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  cursor: default;
  transition: background 0.12s, transform 0.12s, border-color 0.12s;
}

.cell.is-preview {
  border: 1.5px dashed var(--pc);
  color: var(--pc);
  background: rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.cell.is-preview:hover {
  background: var(--pc);
  border-style: solid;
  color: #1d1218;
  transform: scale(1.05);
}

.cell.is-preview.is-zero {
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--faint);
}

.cell.is-preview.is-zero:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.cell.just-picked {
  animation: picked 0.9s ease-out;
}

@keyframes picked {
  0% { background: var(--pc); color: #1d1218; transform: scale(1.15); }
  100% { background: transparent; transform: none; }
}

.sheet tr.sub th,
.sheet tr.grand th {
  padding: 7px 6px;
  text-align: left;
  font-weight: 400;
  font-size: 13px;
  color: var(--muted);
}

.sheet tr.sub td {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--muted);
  padding: 6px 5px;
}

.frac small {
  color: var(--faint);
  font-size: 11px;
}

.mini-meter {
  display: block;
  height: 4px;
  margin: 4px auto 0;
  max-width: 70px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.mini-meter i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--pc);
  transition: width 0.4s;
}

.mini-meter.is-done i {
  background: var(--lime);
}

.mini-meter.is-lost i {
  background: var(--faint);
}

.sheet tr.bonus-row td {
  color: var(--lime);
}

.sheet tr.grand th {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text);
  padding-top: 12px;
}

.sheet tr.grand td {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--pc);
  padding-top: 10px;
  border-bottom: 0;
}

body[data-turn='0'] .sheet tr.grand .p0,
body[data-turn='1'] .sheet tr.grand .p1 {
  border-radius: 0 0 14px 14px;
}

/* ---------- 게임 끝 ---------- */

.over {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 6, 12, 0.66);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade 0.25s ease-out;
}

.over-card {
  position: relative;
  width: min(460px, 100%);
  padding: 26px 22px 24px;
  border-radius: 28px;
  background: linear-gradient(170deg, #2a2030, #18131c);
  border: 1px solid var(--line-2);
  text-align: center;
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  animation: rise 0.45s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle, var(--p0) 3px, transparent 3.5px) 10% 10% / 70px 60px,
    radial-gradient(circle, var(--p1) 3px, transparent 3.5px) 40% 30% / 90px 70px,
    radial-gradient(circle, var(--lime) 2.5px, transparent 3px) 70% 20% / 60px 80px;
  opacity: 0.35;
  animation: confetti 6s linear infinite;
}

.eyebrow {
  position: relative;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.over-card h2 {
  position: relative;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 38px;
  margin-top: 4px;
}

.podium {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 18px 0 14px;
  align-items: end;
}

.podium-p {
  --pc: var(--p0);
  padding: 14px 8px 12px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--line);
}

.podium-p.p1 {
  --pc: var(--p1);
}

.podium-p.is-winner {
  border-color: var(--pc);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.04), 0 20px 40px -20px var(--pc);
  padding-top: 22px;
}

.podium-p .avatar {
  margin: 0 auto;
  width: 84px;
  height: 84px;
}

.podium-p.is-winner .avatar {
  width: 104px;
  height: 104px;
  animation: bob 1.1s ease-in-out infinite;
}

.crown {
  position: absolute;
  left: 50%;
  top: -16px;
  z-index: 2;
  width: 40px;
  height: 26px;
  margin-left: -20px;
  background: linear-gradient(#fff3b0, #ffcf33 50%, #d99a00);
  clip-path: polygon(0 100%, 0 22%, 25% 62%, 50% 0, 75% 62%, 100% 22%, 100% 100%);
}

.fname {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--pc);
  margin-top: 6px;
}

.fscore {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.1;
}

.best-line {
  position: relative;
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 18px;
}

.over-card .primary {
  position: relative;
  width: 100%;
}

@keyframes fade {
  from { opacity: 0; }
}

@keyframes rise {
  from { transform: translateY(30px) scale(0.92); opacity: 0; }
}

@keyframes confetti {
  to { background-position: 10% 130%, 40% 150%, 70% 140%; }
}

/* ---------- 좁은 화면 ---------- */

@media (max-width: 959px) {
  .app {
    max-width: 680px;
  }
}

@media (max-width: 620px) {
  .app {
    padding: 12px 12px 32px;
    gap: 12px;
  }

  h1 {
    font-size: 21px;
  }

  .round-chip {
    font-size: 15px;
    padding: 2px 9px 1px;
  }

  .round-chip small {
    font-size: 11px;
  }

  .ghost {
    padding: 7px 11px;
    font-size: 13px;
  }

  .logo {
    display: none;
  }

  .versus {
    gap: 6px;
  }

  .player,
  .player.p1 {
    flex-direction: column;
    text-align: center;
    gap: 2px;
    padding: 22px 8px 10px;
    border-radius: 20px;
  }

  .avatar {
    width: 62px;
    height: 62px;
  }

  .pname {
    font-size: 17px;
  }

  .pscore strong {
    font-size: 32px;
  }

  .pmeta {
    font-size: 11px;
  }

  .turn-tag,
  .player.p1 .turn-tag {
    top: auto;
    bottom: -10px;
    left: 50%;
    right: auto;
    transform: translate(-50%, 4px) scale(0.9);
  }

  .player.is-active .turn-tag {
    transform: translate(-50%, 0);
  }

  .vs {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .rim {
    padding: 8px;
    border-radius: 20px;
  }

  .rim::before {
    inset: 3px;
    border-radius: 17px;
  }

  .board {
    border-radius: 12px;
  }

  .controls {
    gap: 10px;
  }

  .rack-wrap {
    width: 100%;
    justify-content: space-between;
    padding: 8px 10px;
  }

  .rack {
    gap: 6px;
  }

  .slot {
    width: 46px;
    height: 46px;
  }

  .flat-die {
    padding: 6px;
  }

  .flat-die .pip {
    width: 8px;
    height: 8px;
  }

  .roll-box {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
  }

  .roll {
    flex: 1;
    max-width: 240px;
  }

  .sheet-card {
    padding: 6px 6px 10px;
    border-radius: 20px;
  }

  .sheet .pcol {
    width: 25%;
  }

  .cat {
    gap: 6px;
  }

  .cat-name {
    font-size: 13.5px;
  }

  .cat-rule {
    font-size: 10.5px;
  }

  .cell {
    height: 36px;
    font-size: 15px;
  }

  .sheet tr.grand td {
    font-size: 24px;
  }

  .mini-char {
    width: 30px;
    height: 30px;
  }
}

@media (max-width: 380px) {
  .rack-wrap {
    gap: 8px;
  }

  .rack-label {
    font-size: 13px;
  }

  .slot {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 340px) {
  .top {
    flex-wrap: wrap;
  }

  .round-chip small {
    display: none;
  }

  .avatar {
    width: 50px;
    height: 50px;
  }

  .pscore strong {
    font-size: 26px;
  }

  .pmeta {
    display: none;
  }

  .rack-label {
    display: none;
  }

  .rack-wrap {
    justify-content: center;
  }

  .rack {
    gap: 4px;
  }

  .slot {
    width: 36px;
    height: 36px;
    border-radius: 9px;
  }

  .flat-die {
    padding: 4px;
    border-radius: 9px;
  }

  .flat-die .pip {
    width: 6px;
    height: 6px;
  }

  .cat-rule {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
