:root {
  --bg: #0e1116;
  --panel: #171c24;
  --panel-2: #1e242e;
  --line: #2a323e;
  --fg: #e6eaf0;
  --muted: #8b95a5;
  --accent: #4da3ff;
  --warn: #ffb545;
  --danger: #ff5a5a;
  --good: #46d39a;
  --radius: 12px;
}

* { box-sizing: border-box; }

/* display 를 지정한 요소에도 hidden 이 먹도록. .view 는 display:flex 라 이게 없으면 숨겨지지 않는다. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 "Pretendard", -apple-system, "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { padding: 16px; max-width: 920px; margin: 0 auto; }

h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
button { font: inherit; cursor: pointer; }

.view { display: flex; flex-direction: column; gap: 16px; }

/* ───────── 홈 ───────── */
.hero { text-align: center; padding: 28px 0 4px; }
.hero h1 {
  font-size: 44px; letter-spacing: -.02em; margin-bottom: 8px;
  background: linear-gradient(100deg, #7cc4ff, #46d39a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tag { color: var(--muted); margin: 0; }
.tag b { color: var(--fg); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.panel { display: flex; flex-direction: column; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; color: var(--muted); }
input {
  font: inherit; color: var(--fg);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px; padding: 11px 12px; width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#join-code { text-transform: uppercase; letter-spacing: .22em; font-weight: 700; }

button.primary, button:not(.ghost) {
  background: var(--panel-2); color: var(--fg);
  border: 1px solid var(--line); border-radius: 9px; padding: 11px 14px;
}
button.primary {
  background: linear-gradient(100deg, #2b7fd4, #1f9e78);
  border-color: transparent; font-weight: 700;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 6px 10px; }

.divider { text-align: center; color: var(--muted); font-size: 12px; position: relative; }
.divider::before { content: ""; position: absolute; inset: 50% 0 auto; height: 1px; background: var(--line); }
.divider span { background: var(--panel); padding: 0 10px; position: relative; }

.err { color: var(--danger); margin: 0; font-size: 14px; }
.muted { color: var(--muted); margin: 0; font-size: 13px; }

.rules summary { cursor: pointer; font-weight: 700; }
.rules ol { margin: 12px 0 0; padding-left: 20px; color: var(--muted); }
.rules li { margin-bottom: 7px; }
.rules b { color: var(--fg); }

.ad-slot:empty { display: none; }

/* ───────── 방 ───────── */
.roombar { display: flex; align-items: center; gap: 12px; }
.roombar .code { display: flex; align-items: center; gap: 8px; }
.roombar .label { font-size: 12px; color: var(--muted); }
.roombar .code b { letter-spacing: .2em; font-size: 18px; }
.badge {
  margin-left: auto; font-size: 12px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
}
.badge.live { color: var(--good); border-color: #255a46; }

/* 게이지 */
.gauges { display: flex; gap: 28px; justify-content: center; padding: 8px 0 4px; }
.gauge { width: 112px; text-align: center; }
.tube {
  position: relative; height: 240px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); overflow: hidden;
}
.fill {
  position: absolute; inset: auto 0 0; height: 0%;
  background: linear-gradient(0deg, #1f7ad0, #46d39a);
  transition: height .35s cubic-bezier(.3,.8,.3,1);
}
/* 카드를 고른 동안에만 보이는 결과 미리보기. 고르지 않았을 때 바닥에 점선이 남지 않도록 숨긴다. */
.ghost-fill {
  display: none;
  position: absolute; inset: auto 0 0; height: 0%;
  background: repeating-linear-gradient(45deg, rgba(255,181,69,.35) 0 6px, transparent 6px 12px);
  border-top: 2px dashed var(--warn);
  transition: height .15s linear; pointer-events: none;
}
.gauge.selectable .ghost-fill { display: block; }
.gauge.selectable .ghost-fill.danger {
  background: repeating-linear-gradient(45deg, rgba(255,90,90,.35) 0 6px, transparent 6px 12px);
  border-top-color: var(--danger);
}
.marks { position: absolute; inset: 0; pointer-events: none; }
.marks i {
  position: absolute; left: 0; right: 0; height: 0;
  border-top: 1px dashed rgba(255,255,255,.28);
}
.marks i::after {
  content: attr(data-v); position: absolute; right: 4px; top: -15px;
  font-size: 10px; color: rgba(255,255,255,.45); font-style: normal;
}
.gval { font-size: 30px; font-weight: 800; margin-top: 8px; font-variant-numeric: tabular-nums; }
.gname { font-size: 12px; color: var(--muted); }
.gauge.selectable .tube { cursor: pointer; border-color: var(--warn); }
.gauge.selectable:hover .tube { box-shadow: 0 0 0 2px rgba(255,181,69,.4); }
.gauge.burst .tube { animation: shake .4s; border-color: var(--danger); }
.gauge.snipe .tube { animation: pulse .5s; border-color: var(--good); }
@keyframes shake { 25% { transform: translateX(-5px) } 75% { transform: translateX(5px) } }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(70,211,154,.35) } }

.hint { text-align: center; color: var(--warn); min-height: 1.5em; margin: 4px 0 0; font-size: 14px; }

/* 좌석 */
.seats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.seats li {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; font-size: 14px;
}
.seats li.turn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.seats li.me .nm { color: var(--accent); font-weight: 700; }
.seats li.out { opacity: .4; }
.seats li.off .nm::after { content: " (접속 끊김)"; font-size: 11px; color: var(--muted); }
.seats .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seats .tokens { letter-spacing: 1px; color: var(--warn); }
.seats select { background: var(--panel-2); color: var(--fg); border: 1px solid var(--line); border-radius: 7px; padding: 4px; font: inherit; font-size: 12px; }
.seats .host { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }
.seats .timer { font-variant-numeric: tabular-nums; color: var(--warn); font-size: 12px; }

/* 손패 */
.hand-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hand { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.hand button {
  width: 60px; height: 84px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 20px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  transition: transform .12s, border-color .12s;
}
.hand button:hover:not(:disabled) { transform: translateY(-5px); border-color: var(--accent); }
.hand button.sel { border-color: var(--warn); transform: translateY(-8px); box-shadow: 0 0 0 2px rgba(255,181,69,.35); }
.hand button.neg { color: var(--good); }
.hand button.sp { color: var(--accent); font-size: 24px; }

/* 로그 */
.logs { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.log-col h3 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.log {
  list-style: none; margin: 0; padding: 10px; height: 180px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  font-size: 13px; display: flex; flex-direction: column; gap: 5px;
}
.log li { color: var(--muted); }
.log li b { color: var(--fg); }
.log li.bad b, .log li.bad { color: var(--danger); }
.log li.good b { color: var(--good); }
.chat-form { display: flex; gap: 6px; margin-top: 6px; }
.chat-form input { flex: 1; }

#result h2 { text-align: center; }

@media (max-width: 620px) {
  body { padding: 12px; }
  .hero h1 { font-size: 34px; }
  .logs { grid-template-columns: 1fr; }
  .tube { height: 190px; }
  .gauge { width: 96px; }
  .gauges { gap: 18px; }
}

/* ───────── 홈: 게임 선택 ───────── */
.picker { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.gcard {
  text-align: left; display: flex; flex-direction: column; gap: 5px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; color: var(--fg); transition: border-color .15s, transform .12s;
}
.gcard:hover { border-color: var(--accent); transform: translateY(-2px); }
.gcard.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.gcard b { font-size: 17px; }
.gcard .meta { font-size: 12px; color: var(--muted); }
.gcard .tl { font-size: 13px; color: var(--muted); line-height: 1.45; }

/* ───────── 좌석 점수 ───────── */
.seats .score { letter-spacing: 1px; color: var(--warn); font-variant-numeric: tabular-nums; }
.seats .hc { font-size: 11px; color: var(--muted); }
.chips.plus { color: var(--good); }
.chips.minus { color: var(--danger); }

/* ───────── 조수 ───────── */
.controls { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.tide-top { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.tide-round { font-size: 12px; color: var(--muted); letter-spacing: .08em; }
.tide-trick, .tide-pool, .tide-pick { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tide-trick .lbl, .tide-pool .lbl, .tide-pick .lbl {
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em;
}
.tiles { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; min-height: 46px; align-items: center; }
.tile {
  width: 38px; height: 46px; border-radius: 8px; border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums;
  background: var(--panel-2); transition: transform .12s, box-shadow .12s;
}
button.tile:hover:not(:disabled) { transform: translateY(-4px); }
button.tile:disabled { opacity: .6; }
.tile.c0 { color: #7cc4ff; border-color: #2b5f8f; background: #122232; }
.tile.c1 { color: #ff8a8a; border-color: #8f3a3a; background: #2d1818; }
.tile.c2 { color: #ffd166; border-color: #8a6c22; background: #2b2411; }
.tile.sel { transform: translateY(-7px); box-shadow: 0 0 0 2px var(--warn); }
.tide-pick .verdict { font-size: 13px; min-height: 1.3em; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--danger); }
.controls .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

@media (max-width: 620px) {
  .tile { width: 32px; height: 40px; font-size: 15px; }
  .picker { grid-template-columns: 1fr; }
}

/* ───────── SEO 본문 ───────── */
.crumb { font-size: 13px; color: var(--muted); }
.crumb a { color: var(--muted); }
.crumb span { opacity: .5; margin: 0 2px; }
.meta-line { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.seo {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; line-height: 1.7;
}
.seo h2 { font-size: 16px; margin: 22px 0 10px; }
.seo h2:first-child { margin-top: 0; }
.seo p { color: var(--muted); margin: 0 0 10px; }
.seo-list { color: var(--muted); margin: 0; padding-left: 20px; }
.seo-list li { margin-bottom: 7px; }
.seo-list b { color: var(--fg); }
a { color: var(--accent); }
.gcard { text-decoration: none; }
.gcard .go { font-size: 12px; color: var(--accent); margin-top: 2px; }
