/* Look: ink ground, ivory type, hairlines and square corners, champagne gold used sparingly.
   State colours are jewel tones shared with the 3D scene (app/scene.js COLOR). */
:root {
  --bg: #0d0c0a;
  --surface: #141210;
  --line: #2b2722;
  --ivory: #ede6d8;
  --muted: #9c9385;
  --gold: #b89b5e;
  --gold-hi: #cdb27a;
  --amber: #d6a23e;
  --sapphire: #4a7fd6;
  --ruby: #c9454b;
  --emerald: #3f9f79;
  --sapphire-tint: #a9c4f2;
  --ruby-tint: #f0a3a6;
  --emerald-tint: #9ddcc0;
  --latin: 'Cormorant Garamond', 'Noto Serif KR', serif;
  --serif: 'Noto Serif KR', serif;
  --sans: 'IBM Plex Sans KR', -apple-system, 'Apple SD Gothic Neo', sans-serif;
  --pad: clamp(16px, 3.3vw, 48px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ivory);
  font-family: var(--sans);
  user-select: none;
  -webkit-user-select: none;
}

h1, h2, p, dl, dd, ol { margin: 0; padding: 0; }
hr { width: 100%; height: 1px; margin: 0; border: 0; background: var(--line); }

.overline { font-family: var(--latin); font-size: 13px; font-weight: 600; letter-spacing: 0.34em; color: var(--gold); }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.gem { display: inline-block; width: 7px; height: 7px; flex: none; transform: rotate(45deg); background: var(--muted); }
.gem.hover { background: var(--amber); }
.gem.held { background: var(--sapphire); }
.gem.target { background: var(--ruby); }
.gem.hint { background: var(--emerald); }

.ornament { display: flex; align-items: center; gap: 14px; width: 180px; }
.ornament::before, .ornament::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.ornament .gem { background: var(--gold); }

/* ---------- 3D stage & play layer ---------- */
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#app {
  position: relative;
  height: 100%;
  padding: clamp(16px, 4.4vh, 40px) var(--pad) clamp(14px, 3.5vh, 32px);
  display: grid;
  grid-template: 'hud banner space' auto '. . .' 1fr 'foot foot foot' auto / minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 24px;
  pointer-events: none;
  transition: opacity 0.4s;
}
#app button, #app a { pointer-events: auto; }
.back { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 12px; letter-spacing: 0.12em; color: var(--muted); text-decoration: none; }
.back .icon { width: 14px; height: 14px; }
.back:hover { color: var(--gold); }
body.intro #app, body.intro #cam { opacity: 0; visibility: hidden; }
body.drawer-open #app { opacity: 0.32; }

#hud { grid-area: hud; display: flex; flex-direction: column; gap: 6px; }
#hud h1 { font-family: var(--serif); font-size: 26px; font-weight: 400; letter-spacing: 0.04em; margin-bottom: 12px; }

.stats { display: flex; }
.stats > div { display: flex; flex-direction: column; gap: 2px; padding: 0 22px; border-left: 1px solid var(--line); }
.stats > div:first-child { padding-left: 0; border-left: 0; }
.stats dt { font-size: 12px; letter-spacing: 0.14em; color: var(--muted); white-space: nowrap; }
.stats dd { font-family: var(--latin); font-size: 30px; font-weight: 500; line-height: 1.1; font-variant-numeric: lining-nums; }
.stats.large { justify-content: center; }
.stats.large > div { padding: 0 36px; }
.stats.large dd { font-size: 40px; }

#banner {
  grid-area: banner;
  align-self: start;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(560px, 92vw);
  padding: 14px 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 15px;
  letter-spacing: 0.02em;
  line-height: 1.5;
}
#banner b { font-family: var(--serif); font-weight: 600; }
#banner em { font-style: normal; color: var(--ruby-tint); }

footer { grid-area: foot; display: flex; flex-direction: column; align-items: center; gap: 16px; }

.dock { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 2px; }
.dock button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 190px;
  height: 72px;
  background: transparent;
  color: var(--ivory);
  border: 0;
  border-left: 1px solid var(--line);
  font: 500 15px var(--sans);
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.dock button:first-child { border-left: 0; }
.dock .icon { color: var(--gold); }
.dock button:hover, .dock button.hand-hover { background: #1f1c18; }
.dock button.hand-hover { box-shadow: inset 0 -2px 0 var(--gold); }
.dock button:disabled { color: #5e574d; cursor: default; }
.dock button:disabled .icon { color: #5e574d; }

.legend { display: flex; gap: 28px; font-size: 12px; letter-spacing: 0.1em; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 9px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 72px;
  padding: 0 32px;
  background: transparent;
  color: var(--ivory);
  border: 1px solid var(--line);
  border-radius: 2px;
  font: 500 16px var(--sans);
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn .icon { color: var(--gold); }
.btn:hover, .btn.hand-hover { border-color: var(--gold); background: #1a1714; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #14100a; }
.btn.primary .icon { color: inherit; }
.btn.primary:hover, .btn.primary.hand-hover { background: var(--gold-hi); border-color: var(--gold-hi); }
.btn.tall { height: 76px; font-size: 17px; }
.btn.small { height: 44px; padding: 0 16px; font-size: 13px; letter-spacing: 0.1em; gap: 10px; }
.btn.small .icon { width: 16px; height: 16px; }
.btn.square { width: 48px; height: 48px; padding: 0; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- camera chip ---------- */
#cam {
  position: fixed;
  top: clamp(16px, 4.4vh, 40px);
  right: var(--pad);
  width: 216px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px;
  z-index: 20;
  transition: opacity 0.4s;
}
#cam video { display: none; }
#cam.off { width: auto; padding: 0; border: 0; background: none; }
#cam.off .preview, #cam.off .gauge, #cam.off #btn-tune { display: none; }
#cam:not(.off) #btn-cam-on { display: none; }
body.drawer-open #cam { display: none; }

.preview { position: relative; aspect-ratio: 4 / 3; background: #070605; overflow: hidden; }
.preview.large { border: 1px solid var(--line); }
.preview canvas { display: block; width: 100%; height: 100%; }
.preview .track-status { position: absolute; left: 10px; top: 10px; }
#cam-status { position: absolute; inset: auto 8px 10px; text-align: center; font-size: 11px; letter-spacing: 0.06em; color: var(--muted); }

.track-status { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; letter-spacing: 0.1em; color: var(--muted); text-shadow: 0 1px 2px #000; }
.track-status i { width: 6px; height: 6px; border-radius: 50%; background: #5e574d; }
.tracking-ok .track-status { color: var(--emerald-tint); }
.tracking-ok .track-status i { background: var(--emerald); }
.tracking-lost .track-status { color: #e3c48a; }
.tracking-lost .track-status i { background: var(--amber); }

/* Pinch gauge: bar = finger gap; bright tick = grab threshold, dim tick = release threshold. */
.gauge { position: relative; height: 4px; background: var(--line); }
.gauge b { position: absolute; left: 0; top: 0; height: 100%; width: 0; background: #7d7568; }
.pinching .gauge b { background: var(--sapphire); }
.gauge .tick { position: absolute; top: -5px; width: 1px; height: 14px; background: var(--ivory); left: 25%; }
.gauge .tick.up { background: #7d7568; left: 37%; }

/* ---------- calibration drawer ---------- */
#drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(420px, 100vw);
  padding: 40px 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -40px 0 80px rgba(0, 0, 0, 0.6);
  overflow-y: auto;
  z-index: 40;
}
#drawer[hidden] { display: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-head h2 { margin-top: 6px; font-family: var(--serif); font-size: 26px; font-weight: 400; letter-spacing: 0.04em; }
.drawer-status { display: flex; justify-content: space-between; font-size: 12px; letter-spacing: 0.1em; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 12px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; letter-spacing: 0.06em; }
.field-head output { font-family: var(--latin); font-size: 20px; }
#pinch-state { color: var(--muted); }
.pinching #pinch-state { color: var(--sapphire-tint); }
.field p { font-size: 12px; line-height: 1.6; color: var(--muted); }
.gauge-labels { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: 0.06em; color: var(--muted); }
.drawer-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12px; letter-spacing: 0.08em; color: var(--muted); }

input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 24px; margin: 0; background: transparent; cursor: pointer; }
input[type='range']::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(var(--gold), var(--gold)) 0 / var(--fill, 50%) 100% no-repeat, var(--line); }
input[type='range']::-moz-range-track { height: 2px; background: var(--line); }
input[type='range']::-moz-range-progress { height: 2px; background: var(--gold); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px; border: 0; border-radius: 0; background: var(--ivory); transform: rotate(45deg); }
input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 0; background: var(--ivory); transform: rotate(45deg); }

/* ---------- hand cursor (only shown over UI; on the board the 3D hand is the cursor) ---------- */
#cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 100;
  transition: width 0.1s, height 0.1s, margin 0.1s, background 0.1s;
}
#cursor::after { content: ''; position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; margin: -2.5px; transform: rotate(45deg); background: var(--gold); }
#cursor.pinch { width: 22px; height: 22px; margin: -11px 0 0 -11px; background: rgba(184, 155, 94, 0.45); }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: clamp(130px, 22vh, 190px);
  transform: translateX(-50%);
  max-width: 90vw;
  padding: 14px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 2px;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-align: center;
  z-index: 60;
}

/* ---------- start screen: copy on the left, the live board glides in on the right ---------- */
.start {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  padding: clamp(24px, 6vh, 80px) clamp(20px, 7.2vw, 104px);
  overflow-y: auto;
  z-index: 50;
}
.start[hidden] { display: none; }
.start-copy { width: min(520px, 100%); display: flex; flex-direction: column; gap: 18px; }
.start h2 { font-family: var(--serif); font-size: clamp(40px, 4.4vw, 62px); font-weight: 400; line-height: 1.25; letter-spacing: 0.01em; }
.lead { font-size: 16px; line-height: 1.8; color: var(--muted); }
.steps { list-style: none; margin: 12px 0; }
.steps li { display: flex; gap: 28px; align-items: baseline; padding: 18px 0; border-top: 1px solid var(--line); }
.steps li:first-child { border-top: 0; }
.steps b { width: 40px; flex: none; font-family: var(--latin); font-size: 30px; font-weight: 500; color: var(--gold); }
.steps div { display: flex; flex-direction: column; gap: 4px; }
.steps strong { font-size: 17px; font-weight: 500; letter-spacing: 0.02em; }
.steps span { font-size: 14px; line-height: 1.6; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 14px; }
.fine { font-size: 12px; letter-spacing: 0.04em; line-height: 1.6; color: var(--muted); }

/* ---------- clear screen ---------- */
.modal { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(13, 12, 10, 0.74); z-index: 50; overflow-y: auto; }
.modal[hidden] { display: none; }
.card {
  width: min(540px, 100%);
  padding: 56px 56px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 2px;
  box-shadow: 0 60px 120px rgba(0, 0, 0, 0.7);
}
.card h2 { font-family: var(--serif); font-size: clamp(48px, 6vw, 68px); font-weight: 400; letter-spacing: 0.12em; padding-left: 0.12em; }
.card > p { font-size: 15px; letter-spacing: 0.04em; color: var(--muted); }
.card .stats { margin: 18px 0; }
.stack { display: flex; flex-direction: column; gap: 12px; width: 100%; margin: 6px 0 12px; }
.stack .btn:not(.tall) { height: 64px; font-size: 15px; }

/* ---------- narrow screens ---------- */
@media (max-width: 900px) {
  #app { grid-template: 'hud' auto 'banner' auto '.' 1fr 'foot' auto / minmax(0, 1fr); gap: 14px; }
  #hud .overline { display: none; }
  #hud h1 { font-size: 20px; margin-bottom: 6px; }
  .stats dd { font-size: 24px; }
  .stats > div { padding: 0 14px; }
  #banner { justify-self: center; padding: 10px 16px; font-size: 13px; }
  .dock { width: 100%; }
  .dock button { width: auto; flex: 1; height: 64px; flex-direction: column; gap: 6px; font-size: 12px; letter-spacing: 0.04em; }
  .legend { gap: 16px; font-size: 11px; letter-spacing: 0.04em; }
  #cam { width: 132px; padding: 8px; gap: 8px; }
  #cam .btn.small span { display: none; }
  .start { background: rgba(13, 12, 10, 0.86); align-items: flex-start; }
  .card { padding: 40px 24px 32px; }
  .stats.large > div { padding: 0 20px; }
}

/* ---------- piece tools (pentomino): a second, smaller dock above the main one ---------- */
.dock.tools button { width: 150px; height: 60px; font-size: 14px; }
footer:has(.tools) { gap: 10px; }
footer:has(.tools) .legend { margin-top: 4px; }

/* ---------- game select ---------- */
body.hub { overflow: auto; }
.hub-main { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 48px; padding: clamp(32px, 7vh, 88px) var(--pad); }
.hub-head { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.hub-head h1 { font-family: var(--serif); font-size: clamp(36px, 4.4vw, 58px); font-weight: 400; letter-spacing: 0.04em; }
.hub-games { display: grid; grid-template-columns: repeat(4, minmax(0, 300px)); gap: 24px; }
@media (max-width: 1360px) { .hub-games { grid-template-columns: repeat(2, minmax(0, 380px)); } }
.game-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 36px 36px 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 2px;
  color: var(--ivory);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.game-card:hover, .game-card:focus-visible { border-color: var(--gold); background: #191613; transform: translateY(-3px); outline: none; }
.game-art { width: 100%; height: 150px; margin-bottom: 8px; color: var(--muted); }
.game-card h2 { font-family: var(--serif); font-size: 30px; font-weight: 400; letter-spacing: 0.04em; }
.game-card p { font-size: 15px; line-height: 1.7; color: var(--muted); }
.go { display: inline-flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 14px; letter-spacing: 0.14em; color: var(--gold); }
.go .icon { width: 18px; height: 18px; }
@media (max-width: 900px) {
  .hub-games { grid-template-columns: minmax(0, 420px); }
  .dock.tools button { width: auto; height: 52px; }
}

#tune-wilor { width: 18px; height: 18px; accent-color: var(--gold); cursor: pointer; }
#engine-state { color: var(--emerald-tint) !important; }
.field code { font-family: var(--latin); font-size: 13px; color: var(--ivory); }


.dock button[hidden] { display: none; }


/* ---------- 마작 ---------- */
.stats dd.serif { font-family: var(--serif); font-size: 22px; padding-top: 5px; }
.stats dd.gold { color: var(--gold); }
#seats { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
body.intro #seats, body.intro #hint { visibility: hidden; }
.mj-seat { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--surface); border: 1px solid var(--line); white-space: nowrap; }
.mj-seat .wind { font-family: var(--serif); font-size: 18px; color: var(--gold); }
.mj-seat .nm { font-size: 14px; }
.mj-seat .pts { font-family: var(--latin); font-size: 18px; }
.mj-seat .st { font-size: 11px; letter-spacing: 0.1em; color: var(--ruby-tint); }
.mj-seat.turn { border-color: var(--gold); }
.mj-seat .say, .my-say { position: absolute; top: -40px; left: 50%; transform: translate(-50%, 6px); padding: 6px 16px; background: var(--ivory); color: #14100a; font-family: var(--serif); font-size: 17px; font-weight: 600; opacity: 0; transition: opacity 0.2s, transform 0.2s; }
.mj-seat .say.show { opacity: 1; transform: translate(-50%, 0); }
.my-say { position: static; transform: none; }
.my-say:empty { display: none; } .my-say:not(:empty) { opacity: 1; }
#hint { position: fixed; right: var(--pad); top: clamp(16px, 4.4vh, 40px); width: 250px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--line); z-index: 6; }
#hint-body p { font-size: 13px; line-height: 1.9; }
#hint-body b { color: var(--gold); font-family: var(--serif); }
body.mj #cam { top: auto; bottom: clamp(14px, 3.5vh, 32px); }
.mj-tile { display: inline-flex; width: 24px; height: 32px; margin: 0 1px; vertical-align: middle; background: #f1ead8; border-radius: 3px; border-bottom: 3px solid #1d6a4b; box-shadow: 0 2px 4px rgba(0,0,0,0.4); }
.mj-tile { padding: 3px 3px 2px; box-sizing: border-box; }
.mj-tile img { width: 100%; height: 100%; object-fit: contain; }
.mj-row .mj-tile { width: 38px; height: 52px; }
.mj-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 1px; margin: 8px 0; }
.mj-row .gap { width: 12px; }
.mj-row .win .mj-tile { box-shadow: 0 0 0 2px var(--gold); }
#callbox { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); width: min(520px, 92vw); padding: 22px 26px; display: flex; flex-direction: column; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-top-color: var(--gold); box-shadow: 0 40px 90px rgba(0,0,0,0.7); z-index: 30; }
#callbox[hidden] { display: none; }
#call-what { font-size: 16px; }
#callbox .timer { display: block; width: 100%; height: 3px; background: var(--line); }
#callbox .timer b { display: block; height: 3px; background: var(--gold); }
#call-opts { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.call-opt { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 16px; background: #1c1812; color: var(--ivory); border: 1px solid var(--gold); border-radius: 2px; font: 500 17px var(--serif); cursor: pointer; }
.call-opt:hover, .call-opt.hand-hover { background: #2a241b; }
#b-riichi.on { background: var(--ruby); color: var(--ivory); }
.card.wide { width: min(780px, 100%); }
#res-yaku { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 36px; row-gap: 6px; width: min(440px, 100%); }
#res-yaku div { display: flex; justify-content: space-between; padding-bottom: 5px; border-bottom: 1px solid var(--line); font-family: var(--serif); font-size: 15px; }
#res-yaku b { font-family: var(--latin); font-size: 18px; color: var(--gold); font-weight: 500; }
#res-points { display: flex; align-items: baseline; gap: 16px; margin: 8px 0; }
#res-points .han { font-family: var(--latin); font-size: 22px; color: var(--muted); }
#res-points b { font-family: var(--latin); font-size: 46px; font-weight: 500; color: var(--gold); }
#res-points .split { font-size: 13px; color: var(--muted); }
#res-scores, #end-scores { display: flex; width: 100%; border-top: 1px solid var(--line); padding-top: 14px; }
#res-scores div, #end-scores div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
#res-scores div + div, #end-scores div + div { border-left: 1px solid var(--line); }
#res-scores dt, #end-scores dt { font-size: 12px; letter-spacing: 0.1em; color: var(--muted); }
#res-scores dd, #end-scores dd { font-family: var(--latin); font-size: 22px; }
#res-scores .up { color: var(--emerald-tint); font-size: 12px; } #res-scores .down { color: var(--ruby-tint); font-size: 12px; }
#end-scores { flex-direction: column; gap: 8px; } #end-scores div { flex-direction: row; justify-content: space-between; width: 100%; } #end-scores div + div { border-left: 0; }
#modal-end .stack a.btn { text-decoration: none; height: 64px; }
@media (max-width: 1000px) { #hint { display: none; } }

.hint-head { display: flex; justify-content: space-between; align-items: center; }
body.mj #hint { width: 300px; max-height: calc(100vh - 200px); overflow-y: auto; }
body.guide #hint-body { display: none; } body:not(.guide) #guide-body { display: none; }
#guide-body h3 { margin: 10px 0 4px; font-family: var(--serif); font-size: 16px; font-weight: 600; color: var(--gold); }
#guide-body h3:first-child { margin-top: 0; }
#guide-body p { font-size: 13px; line-height: 1.75; color: var(--ivory); margin: 0 0 6px; }
#guide-body b { color: var(--gold); font-weight: 500; }
#guide-body .muted { color: var(--muted); font-size: 12px; }
.call-opt.rec, #b-pass.rec { box-shadow: 0 0 0 2px var(--emerald); }
.call-opt.rec::after { content: '추천'; font: 500 11px var(--sans); letter-spacing: 0.1em; color: var(--emerald-tint); }
.guide-check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.6; color: var(--muted); cursor: pointer; }
.guide-check b { color: var(--ivory); } .guide-check input { margin-top: 5px; accent-color: var(--gold); }

#tile-tags { position: fixed; inset: 0; pointer-events: none; z-index: 6; }
body.intro #tile-tags { visibility: hidden; }
.tile-tag { position: absolute; left: 0; top: 0; padding: 3px 8px; background: rgba(20, 18, 16, 0.88); border: 1px solid var(--line); color: var(--ivory); font-size: 12px; letter-spacing: 0.04em; white-space: nowrap; }
.tile-tag.best { border-color: var(--emerald); color: var(--emerald-tint); font-weight: 600; }
#guide-body ol.cands { list-style: none; margin: 4px 0 8px; padding: 0; display: flex; flex-direction: column; gap: 5px; }
#guide-body ol.cands li { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 1.4; color: var(--muted); padding: 4px 6px; border: 1px solid transparent; }
#guide-body ol.cands li.best { border-color: var(--emerald); color: var(--ivory); }
#guide-body ol.cands .no { font-size: 15px; color: var(--gold); width: 16px; }
#guide-body .why { color: var(--emerald-tint); }

/* ---------- luxury motion: slow gold breathing, light sweeps, reward entrance ---------- */
@keyframes gold-breathe {
  0%, 100% { box-shadow: 0 0 0 1px rgba(184, 155, 94, 0.35), 0 0 14px rgba(184, 155, 94, 0.08); }
  50% { box-shadow: 0 0 0 1px rgba(205, 178, 122, 0.8), 0 0 26px rgba(205, 178, 122, 0.28); }
}
@keyframes sweep { from { transform: translateX(-120%) skewX(-18deg); } to { transform: translateX(320%) skewX(-18deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(26px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes shine { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes tag-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(63, 159, 121, 0.0); } 50% { box-shadow: 0 0 14px 2px rgba(63, 159, 121, 0.45); } }

.btn.primary, body.mj .dock button:not([hidden]), .call-opt { position: relative; overflow: hidden; }
.btn.primary::after, body.mj .dock button::after, .call-opt::before {
  content: ''; position: absolute; top: 0; bottom: 0; width: 34%; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 244, 214, 0.28), transparent);
  animation: sweep 3.6s ease-in-out infinite; animation-delay: 1.2s;
}
body.mj .dock button { color: var(--gold-hi); animation: gold-breathe 2.6s ease-in-out infinite; }
#b-tsumo:not([hidden]) { background: var(--gold); color: #14100a; }
#banner { transition: border-color 0.4s, box-shadow 0.4s; }
body.mj #banner { animation: gold-breathe 3.2s ease-in-out infinite; }
.mj-seat.turn { animation: gold-breathe 1.8s ease-in-out infinite; border-color: var(--gold); }
#callbox { animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), gold-breathe 2.2s ease-in-out 0.35s infinite; }
.tile-tag.best { animation: tag-pulse 1.8s ease-in-out infinite; }
#hint { transition: box-shadow 0.4s; }

#result .card.enter { animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
#result .card.enter #res-yaku div { animation: fade-up 0.4s ease-out both; animation-delay: calc(0.45s + var(--i, 0) * 0.12s); }
#result .card.enter .mj-row .mj-tile { animation: fade-up 0.35s ease-out both; }
#result .card.enter .mj-row .mj-tile:nth-child(n) { animation-delay: 0.3s; }
#result .card.mine { border-top: 1px solid var(--gold-hi); animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both, gold-breathe 2.4s ease-in-out 0.6s infinite; }
#result .card.mine #res-title, #result .card.mine #res-points b {
  background: linear-gradient(100deg, #b89b5e 20%, #fff1c9 40%, #d6b56a 55%, #b89b5e 80%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 2.8s linear infinite;
}
#result .card.mine .mj-row .win .mj-tile { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 22px rgba(242, 207, 122, 0.6); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }

.sound-toggle { pointer-events: auto; margin-top: 8px; align-self: flex-start; }
.sound-toggle.off { opacity: 0.55; }

/* ---------- 고스톱 ---------- */
.gs-card { width: 34px; height: 55px; border-radius: 3px; box-shadow: 0 2px 5px rgba(0,0,0,0.45); display: inline-block; vertical-align: middle; }
.gs-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 14px 0 6px; }
.gs-group { display: inline-flex; }
.gs-group .gs-card + .gs-card { margin-left: -16px; }
#result .card.enter .gs-group { animation: fade-up 0.4s ease-out 0.25s both; }
#result .card.mine .gs-card { box-shadow: 0 0 0 1px var(--gold-hi), 0 0 14px rgba(242,207,122,0.45); }
.bak { font-style: normal; font-size: 11px; padding: 1px 6px; margin-left: 6px; background: #c9454b; color: var(--ink, #ede6d8); }
.stack.row2 { flex-direction: row; justify-content: flex-end; gap: 12px; }
.mj-seat.danger .st { color: #f0a3a6; }
body.gs #hud dd small { font-size: 0.55em; color: var(--muted, #9c9385); }
#guide-body .why { color: #bdb4a5; font-size: 13px; }
#guide-body .goal { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 13px; color: #bdb4a5; }
#guide-body b.rec { color: #f2d08a; }

#big-say { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 30; pointer-events: none;
  font-family: 'Noto Serif KR', serif; font-size: 88px; font-weight: 600; letter-spacing: 0.06em; color: #f2d08a;
  text-shadow: 0 0 30px rgba(242,208,138,0.55), 0 6px 30px rgba(0,0,0,0.8); white-space: nowrap; }
#big-say.pop { animation: big-pop 1.3s cubic-bezier(0.2, 0.9, 0.2, 1) both; }
@keyframes big-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(0.94); }
  24% { transform: translate(-50%, -50%) scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(1); }
}

.gs-decide { text-align: center; }
.gs-decide h2 { font-size: 40px; }
.gs-decide h2 #dec-score { font-family: 'Cormorant Garamond', serif; font-size: 1.8em; color: #f2d08a; margin-right: 6px; }
#dec-parts { display: flex; gap: 18px; justify-content: center; margin: 6px 0 22px; color: #bdb4a5; font-size: 14px; }
#dec-parts b { color: #f2d08a; margin-left: 6px; font-family: 'Cormorant Garamond', serif; font-size: 18px; }
.dec-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dec-btn { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 26px 16px 22px;
  background: #141210; color: #ede6d8; border: 1px solid #4a443c; cursor: pointer; font: inherit; --hold: 0; }
.dec-btn svg { width: 64px; height: 64px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.dec-btn b { font-family: 'Noto Serif KR', serif; font-size: 40px; letter-spacing: 0.1em; font-weight: 600; }
.dec-btn span { font-size: 13px; color: #bdb4a5; }
.dec-btn small { font-size: 12px; color: #9c9385; min-height: 1.2em; }
.dec-btn.go { color: #f2d08a; border-color: #f2d08a; animation: gold-breathe 2.2s ease-in-out infinite; }
.dec-btn:hover, .dec-btn.hand-hover { background: #1c1915; }
.dec-btn .hold { position: absolute; left: 0; bottom: 0; height: 4px; width: calc(var(--hold) * 100%); background: #f2d08a; transition: width 0.08s linear; }
.dec-risk { margin: 16px 0 4px; font-size: 13.5px; color: #f0a3a6; }

.gs-mini { width: 20px; height: 33px; border-radius: 2px; vertical-align: middle; margin: 0 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.5); }
#guide-body ol.cands li .gs-mini { flex-shrink: 0; }
#guide-body .note { margin-top: 10px; padding: 8px 10px; border: 1px solid rgba(214,162,62,0.45); background: rgba(214,162,62,0.07); animation: fade-up 0.35s ease-out both; }
#guide-body .note h3 { font-size: 13px; margin: 0 0 4px; }
.gs-progress { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.08); }
.gs-progress h3 { font-size: 14px !important; }
.gs-progress h3 small { font-family: var(--sans, sans-serif); font-size: 11px; color: #9c9385; margin-left: 6px; font-weight: 400; }
.gs-prog { display: grid; grid-template-columns: 44px 1fr 64px; align-items: center; gap: 8px; font-size: 12px; color: #bdb4a5; margin: 4px 0; }
.gs-prog i { height: 4px; background: #2b2722; position: relative; }
.gs-prog i b { position: absolute; left: 0; top: 0; bottom: 0; background: #b89b5e; transition: width 0.4s; }
.gs-prog em { font-style: normal; text-align: right; font-size: 11px; color: #9c9385; }
.gs-prog.done span, .gs-prog.done em { color: #f2d08a; }
.gs-prog.done i b { background: #f2d08a; box-shadow: 0 0 8px rgba(242,208,138,0.6); }

#fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }
#flash { position: fixed; inset: 0; z-index: 55; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 45%, rgba(255,246,220,0.9), rgba(242,208,138,0.35) 45%, transparent 75%); }
#flash.on { animation: flash 0.7s ease-out both; }
#flash.on.strong { animation: flash-strong 1.1s ease-out both; }
@keyframes flash { 0% { opacity: 0.75; } 100% { opacity: 0; } }
@keyframes flash-strong { 0% { opacity: 1; background-color: rgba(255,255,255,0.55); } 30% { opacity: 0.8; } 100% { opacity: 0; } }
#big-say { z-index: 58; }
#big-say.victory { font-size: 150px; color: #fff4d6; animation: victory 2.2s cubic-bezier(0.2, 0.9, 0.2, 1) both; }
@keyframes victory {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); filter: brightness(1); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.4); filter: brightness(5); text-shadow: 0 0 60px #fff, 0 0 120px #f2d08a, 0 0 200px #d6a23e; }
  34% { transform: translate(-50%, -50%) scale(1); filter: brightness(1.3); text-shadow: 0 0 30px #f2d08a, 0 0 80px rgba(214,162,62,0.8); }
  82% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1); }
}
#guide-body p { margin: 0 0 4px; }
#guide-body .gs-mini { width: 22px; height: 36px; }
@media (prefers-reduced-motion: reduce) { #fx-canvas, #flash { display: none; } }

/* 고스톱: peek at the opponents' captured cards */
.peek-toggle { pointer-events: auto; margin-top: 8px; align-self: flex-start; }
.peek-toggle kbd { font-family: inherit; font-size: 10px; padding: 0 4px; margin-left: 4px; border: 1px solid var(--line); color: var(--muted); }
.peek-toggle.on { color: var(--gold-hi); border-color: var(--gold); }
#peek { position: fixed; left: 0; right: 0; margin: 0 auto; top: 110px; z-index: 40; width: min(880px, calc(100vw - 32px));
  padding: 18px 22px; background: rgba(20,18,16,0.96); border: 1px solid var(--gold); box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 30px rgba(184,155,94,0.15);
  display: flex; flex-direction: column; gap: 10px; animation: rise 0.18s ease-out both; pointer-events: none; }
#peek[hidden] { display: none; }
#peek-body { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.peek-player h3 { font-family: var(--serif); font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.peek-player h3 small { font-family: inherit; font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.peek-row { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 8px; min-height: 60px; }
.peek-kind { font-size: 12px; color: var(--muted); }
.peek-kind b { font-family: var(--latin); font-size: 17px; color: var(--ivory); margin-left: 2px; }
.peek-kind.gold, .peek-kind.gold b { color: #f2d08a; }
.peek-kind.warn, .peek-kind.warn b { color: #f0a3a6; }
.peek-row em { color: var(--muted); font-style: normal; }
#peek .gs-card { width: 34px; height: 55px; }
#peek .gs-group .gs-card + .gs-card { margin-left: -12px; }
@media (max-width: 760px) { #peek-body { grid-template-columns: 1fr; } }

/* ---------- 물놀이 ---------- */
.water-tools { display: flex; gap: 8px; margin-top: 8px; pointer-events: auto; }
body.water #banner { pointer-events: none; }

/* particle water (jeantimex/fluid): its own WebGPU canvas under the UI */
#fluid { position: fixed; inset: 0; width: 100vw; height: 100vh; display: none; touch-action: none; }
body.water.fluid #fluid { display: block; }
body.water.fluid #stage { display: none; }
#dip { position: fixed; left: 0; top: 0; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  border: 2px solid rgba(242,208,138,0.85); box-shadow: 0 0 16px rgba(242,208,138,0.45); pointer-events: none; z-index: 5; }
#dip.pull { border-color: rgba(157,220,192,0.9); box-shadow: 0 0 16px rgba(157,220,192,0.5); width: 30px; height: 30px; margin: -15px 0 0 -15px; }
body.water.fluid #b-surfer { display: none; }
/* Splash's backdrop is a bright photo: keep the HUD readable over it */
body.water.fluid #hud { text-shadow: 0 1px 8px rgba(0,0,0,0.7); }
body.water.fluid #hud .btn { background: rgba(13,12,10,0.55); }
body.water.fluid::before { content: ''; position: fixed; left: 0; top: 0; right: 0; height: 220px; z-index: 1; pointer-events: none;
  background: linear-gradient(rgba(13,12,10,0.55), rgba(13,12,10,0)); }

body.water.fluid #hud { text-shadow: none; }
body.water.fluid::before { display: none; }
/* on the white bathroom tiles the HUD goes dark */
body.water.fluid #hud h1, body.water.fluid #hud .back { color: #25282a; }
body.water.fluid #hud .btn { background: rgba(20,22,24,0.78); color: #f1efe8; }

/* 고스톱: keep the table clear — tools on one row, the guide in the empty bottom-left corner */
body.gs .hud-tools { display: flex; gap: 6px; margin-top: 4px; }
body.gs .hud-tools .btn.small { height: 34px; padding: 0 12px; font-size: 12px; margin: 0; }
body.gs .stats dd { font-size: 24px; }
body.gs #hint { left: var(--pad); right: auto; top: auto; bottom: var(--pad); width: 270px; max-height: 42vh; overflow-y: auto;
  padding: 10px 12px; gap: 6px; background: rgba(20,18,16,0.82); }
body.gs #hint .hint-head .btn.small { height: 30px; padding: 0 10px; font-size: 11px; }
body.gs #guide-body p, body.gs #guide-body .why, body.gs #guide-body .goal { font-size: 12px; line-height: 1.6; }
body.water.fluid #cam .btn { background: rgba(20,22,24,0.78); color: #f1efe8; border-color: rgba(20,22,24,0.9); }

/* ---------- 궤도 방어 (orbit) ---------- */
body.orbit { background: #05060a; }
body.orbit .hud-tools { display: flex; gap: 6px; margin-top: 4px; }
body.orbit .hud-tools .btn.small { height: 34px; padding: 0 12px; font-size: 12px; margin: 0; }
body.orbit kbd { font-family: inherit; font-size: 10px; padding: 0 4px; margin-left: 2px; border: 1px solid var(--line); color: var(--muted); }
body.orbit .stats dd { font-size: 26px; }
body.orbit .stats dd small { font-family: var(--sans); font-size: 11px; letter-spacing: 0.12em; color: var(--ruby-tint); }
.o-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.o-row { display: flex; align-items: center; gap: 10px; min-height: 16px; }
.o-lbl { width: 34px; font-size: 11px; letter-spacing: 0.12em; color: var(--muted); }
.o-key { font-size: 11px; color: var(--muted); }
.pips { display: flex; gap: 4px; }
.pips i { display: block; width: 20px; height: 7px; background: #2a2622; }
.pips.hull i.on { background: var(--emerald); box-shadow: 0 0 8px rgba(63, 159, 121, 0.6); }
.pips.hull i.shield { background: #8ff0c8; }
.pips.emp i { width: 11px; height: 11px; transform: rotate(45deg); border: 1px solid #7ee8ff; background: transparent; margin: 0 3px; }
.pips.emp i.on { background: #7ee8ff; box-shadow: 0 0 10px rgba(126, 232, 255, 0.7); }
.chip { font-size: 12px; padding: 2px 8px; border: 1px solid var(--line); background: rgba(20, 18, 16, 0.8); color: #7ee8ff; }
.chip.pierce { color: #d2b8ff; } .chip.rapid { color: #f2c46b; }
body.orbit #banner { padding: 10px 20px; font-size: 14px; background: rgba(20, 18, 16, 0.85); }

#o-boss { position: fixed; left: 50%; top: 86px; transform: translateX(-50%); width: min(460px, 60vw); text-align: center; z-index: 5; pointer-events: none; }
#o-boss[hidden] { display: none; }
#o-boss .overline { font-size: 11px; color: var(--ruby-tint); }
#o-boss .nm { font-family: var(--serif); font-size: 16px; letter-spacing: 0.08em; margin-top: 2px; }
#o-boss .bar { height: 7px; margin-top: 6px; background: #231f1b; border: 1px solid var(--line); }
#o-boss .bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--ruby), #e0676c); box-shadow: 0 0 12px rgba(201, 69, 75, 0.6); transition: width 0.15s; }
#o-boss .ph { display: flex; justify-content: center; gap: 6px; margin-top: 6px; }
#o-boss .ph i { display: block; width: 28px; height: 3px; background: #3a3430; }
#o-boss .ph i.on { background: var(--ruby); }

#o-dial { position: fixed; right: var(--pad); bottom: clamp(16px, 4.4vh, 40px); width: 216px; padding: 12px; background: rgba(20, 18, 16, 0.9); border: 1px solid var(--line); z-index: 20; display: flex; flex-direction: column; gap: 6px; transition: border-color 0.2s, box-shadow 0.2s; }
#o-dial[hidden] { display: none; }
#o-dial svg { width: 100%; display: block; }
#o-dial.grab { border-color: var(--gold); }
#o-dial.fist { border-color: #7ee8ff; box-shadow: 0 0 18px rgba(126, 232, 255, 0.35); }
.o-dial-read { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.o-dial-read #o-dial-aim { color: #7ee8ff; }
.o-dial-state { font-size: 12px; color: var(--ivory); }
#o-dial .btn.small { height: 30px; font-size: 11px; }
body.intro #o-dial, body.intro #o-boss { visibility: hidden; }

/* ---------- 성냥개비 (match) ---------- */
body.match .hud-tools { display: flex; gap: 6px; margin-top: 4px; }
body.match .hud-tools .btn.small { height: 34px; padding: 0 12px; font-size: 12px; margin: 0; }
body.match .tab[aria-pressed="true"] { border-color: var(--gold); color: var(--gold-hi); }
body.match .stats dd { font-size: 26px; }
.m-id { font-size: 11px; letter-spacing: 0.12em; color: var(--muted); margin-top: 6px; }
.m-moves { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); letter-spacing: 0.08em; }
.m-moves i { display: block; width: 30px; height: 6px; border-radius: 3px; background: #3a3129; }
.m-moves i.used { background: var(--amber); box-shadow: 0 0 8px rgba(214, 162, 62, 0.6); }
body.match .dock button { width: 150px; height: 60px; }
.m-other { font-size: 14px; color: var(--muted); }
.m-other b { color: var(--gold-hi); font-weight: 500; }

/* ---------- 주차장 탈출 (parking) ---------- */
body.parking .hud-tools, body.laser .hud-tools, body.domino .hud-tools, body.hacker .hud-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
body.parking .hud-tools .btn.small, body.laser .hud-tools .btn.small, body.domino .hud-tools .btn.small, body.hacker .hud-tools .btn.small { height: 32px; padding: 0 10px; font-size: 12px; margin: 0; }
body.parking .tab[aria-pressed="true"], body.laser .tab[aria-pressed="true"], body.domino .tab[aria-pressed="true"], body.hacker .tab[aria-pressed="true"] { border-color: var(--gold); color: var(--gold-hi); }
body.parking .tab:disabled, body.laser .tab:disabled, body.domino .tab:disabled, body.hacker .tab:disabled { opacity: 0.35; }
body.parking .stats dd, body.laser .stats dd, body.domino .stats dd, body.hacker .stats dd { font-size: 26px; }
body.parking .stats dd small, body.laser .stats dd small, body.domino .stats dd small, body.hacker .stats dd small { font-family: var(--sans); font-size: 12px; color: var(--muted); }
body.parking .dock button, body.laser .dock button, body.domino .dock button, body.hacker .dock button { width: 136px; height: 60px; }
.p-stars { font-size: 34px; letter-spacing: 8px; color: var(--gold-hi); text-align: center; }
body.parking .p-levels, body.laser .p-levels, body.domino .p-levels, body.hacker .p-levels { display: contents; }
/* narrow windows: the dock shares the width instead of running off the screen */
@media (max-width: 700px) {
  body.parking .dock, body.match .dock, body.laser .dock, body.domino .dock, body.hacker .dock { width: calc(100vw - 32px); }
  body.parking .dock button, body.match .dock button, body.laser .dock button, body.domino .dock button, body.hacker .dock button { width: auto; flex: 1; height: 52px; padding: 0 6px; gap: 6px; font-size: 12px; letter-spacing: 0.02em; }
}

/* 해커: which of the three phases you're in */
.h-phase { display: flex; gap: 6px; align-items: center; margin-top: 8px; font-size: 13px; color: var(--muted); }
.h-phase span { padding: 3px 8px; border: 1px solid rgba(255,255,255,0.12); border-radius: 999px; }
.h-phase span.on { color: var(--gold-hi); border-color: var(--gold); }
.h-phase span.past { color: #7dffb4; border-color: rgba(125,255,180,0.4); }
.h-phase i { font-style: normal; opacity: 0.5; }
