/* ═══════════════════════════════════════════════════
   세모 게임실 — 공통 화면
   먹색 바탕 + 삼원색 세 가지 = 세 종류의 삼각형
     예각 = 주홍   직각 = 코발트   둔각 = 샛노랑
   세 색은 "삼각형 종류"에만 쓴다. 정답을 드러내는 곳(판정 후)에서만 칠한다.
   ═══════════════════════════════════════════════════ */

:root {
  --bg:    #0C0E12;
  --bg2:   #13161C;
  --bg3:   #1A1E26;
  --bg4:   #232834;
  --line:  rgba(242, 237, 227, .08);
  --line2: rgba(242, 237, 227, .16);
  --line3: rgba(242, 237, 227, .32);
  --paper: #F2EDE3;
  --mute:  #9197A1;
  --dim:   #5E646E;

  --acute:  #FF5A36;
  --right:  #3D7CFF;
  --obtuse: #FFB81C;
  --glow:   #62F0D3;
  --good:   #62F0D3;
  --bad:    #FF5A36;

  --r-s: 8px;
  --r:   14px;
  --r-l: 22px;

  --ff: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --fm: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--paper);
  font-family: var(--ff);
  font-size: 18px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
kbd {
  font-family: var(--fm); font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 6px;
  color: var(--mute); background: var(--bg2);
}
[hidden] { display: none !important; }

#app { height: 100dvh; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ── 공통 버튼 ──────────────────────────────── */
.tbtn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line2); background: transparent;
  font-size: 15px; font-weight: 650; color: var(--paper);
  text-decoration: none; cursor: pointer;
  transition: background .2s, border-color .2s;
}
.tbtn:hover { background: var(--bg3); border-color: var(--line3); }
.tbtn.icon { width: 40px; padding: 0; justify-content: center; }
.tbtn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tbtn.dot::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--glow); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 56px; padding: 0 28px; border-radius: 14px;
  border: 1px solid var(--line2); background: var(--bg3);
  font-size: 19px; font-weight: 750; cursor: pointer; letter-spacing: -.01em;
  transition: transform .15s var(--ease), background .2s, border-color .2s;
}
.btn:hover { border-color: var(--line3); background: var(--bg4); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { background: var(--paper); color: var(--bg); border-color: var(--paper); }
.btn.primary:hover { background: #fff; }
.btn kbd { background: transparent; }
.btn.primary kbd { color: rgba(12,14,18,.55); border-color: rgba(12,14,18,.25); }

/* ── 홈 상단바 ─────────────────────────────── */
.topbar {
  flex: none; height: 64px; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 30px; height: 30px; }
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.topbar-tools { display: flex; gap: 8px; align-items: center; }

/* ── 홈 ──────────────────────────────────────── */
.home {
  flex: 1; min-height: 0; padding: 22px 28px 20px;
  display: grid; grid-template-rows: auto 1fr auto; gap: 18px;
}
.home-head { display: flex; align-items: baseline; justify-content: space-between; }
.home-head h1 { font-size: 40px; font-weight: 850; letter-spacing: -.035em; line-height: 1; }
.home-keys { display: flex; gap: 6px; }

.posters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; min-height: 0; }
.poster {
  position: relative; min-height: 0; overflow: hidden;
  display: grid; grid-template-rows: 1fr auto;
  border-radius: var(--r-l); border: 1px solid var(--line);
  background: var(--bg2); cursor: pointer; text-align: left; padding: 0;
  transition: transform .35s var(--ease), border-color .3s, box-shadow .35s var(--ease);
}
.poster:hover, .poster:focus-visible {
  transform: translateY(-4px);
  border-color: var(--line3);
  box-shadow: 0 24px 60px -24px rgba(0,0,0,.8);
  outline: none;
}
.poster-art { position: relative; min-height: 0; overflow: hidden; }
.poster-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.poster-art svg .spin { transform-box: fill-box; transform-origin: 50% 60%; transition: transform .7s var(--ease); }
.poster:hover .poster-art svg .spin { transform: rotate(90deg); }
.poster-art svg .float { transition: transform .7s var(--ease); }
.poster:hover .poster-art svg .float { transform: translate(-10px, -8px); }
.poster-num {
  position: absolute; top: 16px; left: 20px; z-index: 2;
  font-family: var(--fm); font-size: 15px; font-weight: 800; letter-spacing: .04em;
  color: var(--paper); mix-blend-mode: difference;
}
.poster-key { position: absolute; top: 14px; right: 16px; z-index: 2; }
.poster-info { padding: 18px 22px 20px; border-top: 1px solid var(--line); background: var(--bg2); }
.poster-info h2 { font-size: 30px; font-weight: 850; letter-spacing: -.035em; line-height: 1.15; }
.poster-line { margin-top: 6px; font-size: 16px; color: var(--mute); line-height: 1.45; }
.poster-meta { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px; }
.poster-who { white-space: nowrap; }
.poster-who { font-size: 14px; color: var(--mute); }
.poster-who b { color: var(--paper); font-weight: 700; }
.tri-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tri-tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line2); font-size: 13px; font-weight: 700; color: var(--paper);
}
.tri-tag i { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid currentColor; }
.tri-tag.acute i  { color: var(--acute); }
.tri-tag.right i  { color: var(--right); }
.tri-tag.obtuse i { color: var(--obtuse); }
.tri-tag.move i   { color: var(--paper); border: 0; width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; }

.teams {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg2);
}
.teams-label { font-size: 14px; font-weight: 750; color: var(--mute); margin-right: 6px; white-space: nowrap; }
.teams-label b { color: var(--paper); font-family: var(--fm); }
.team {
  flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0;
  height: 44px; padding: 0 14px; border-radius: 10px; background: var(--bg3);
  font-size: 14px; white-space: nowrap; overflow: hidden;
}
.team b { font-family: var(--fm); font-size: 13px; color: var(--mute); }
.team span { overflow: hidden; text-overflow: ellipsis; }
.team.wait { background: transparent; border: 1px dashed var(--line2); color: var(--dim); }
.team.wait b { color: var(--dim); }

/* ── 게임 상단바 ─────────────────────────────── */
.gbar {
  flex: none; height: 72px; padding: 0 18px 0 12px;
  display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.gback {
  flex: none; display: flex; align-items: center; gap: 6px;
  height: 48px; padding: 0 12px 0 8px; border-radius: 12px;
  border: 1px solid var(--line2); background: transparent; cursor: pointer;
}
.gback:hover { background: var(--bg3); }
.gback svg { width: 24px; height: 24px; stroke: var(--paper); stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.gtitle { flex: none; display: flex; align-items: center; gap: 12px; }
.gnum { font-family: var(--fm); font-size: 14px; font-weight: 800; color: var(--mute); }
.gtitle h2 { font-size: 22px; font-weight: 850; letter-spacing: -.03em; line-height: 1.15; }
.gtitle p { font-size: 13px; color: var(--mute); }
.gtools { flex: none; display: flex; gap: 8px; margin-left: auto; }

.stage { flex: 1; min-height: 0; position: relative; overflow: hidden; }

/* ── 결과 오버레이 ───────────────────────────── */
.overlay {
  position: fixed; inset: 72px 0 0 0; z-index: 60;   /* 위쪽 막대(뒤로·기획안·편지)는 덮지 않는다 */
  display: grid; place-items: center;
  background: rgba(8, 9, 12, .62); backdrop-filter: blur(6px);
  animation: fade .25s ease;
}
.ov-card {
  width: min(560px, 92vw); padding: 36px 36px 30px; border-radius: var(--r-l);
  background: var(--bg2); border: 1px solid var(--line2);
  box-shadow: 0 40px 100px -30px rgba(0,0,0,.9);
  animation: rise .4s var(--ease);
}
.ov-kicker { font-family: var(--fm); font-size: 13px; font-weight: 800; letter-spacing: .08em; color: var(--glow); text-transform: uppercase; }
.ov-card h3 { margin-top: 8px; font-size: 48px; font-weight: 900; letter-spacing: -.04em; line-height: 1.05; }
.ov-body { margin-top: 18px; color: #D5D0C6; font-size: 17px; }
.ov-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.ov-stat { padding: 12px 14px; border-radius: 12px; background: var(--bg3); }
.ov-stat b { display: block; font-family: var(--fm); font-size: 28px; font-weight: 800; color: var(--paper); line-height: 1.1; }
.ov-stat span { font-size: 13px; color: var(--mute); }
.ov-note { margin-top: 14px; font-size: 16px; line-height: 1.55; }
.ov-actions { margin-top: 26px; display: flex; gap: 10px; }
.ov-actions .btn { flex: 1; }

/* ── 모달 ────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center; padding: 3vh 3vw;
  background: rgba(8, 9, 12, .7); backdrop-filter: blur(6px);
  animation: fade .2s ease;
}
.modal-card {
  width: min(1180px, 100%); height: min(88vh, 900px);
  display: flex; flex-direction: column;
  border-radius: var(--r-l); background: var(--bg2); border: 1px solid var(--line2);
  overflow: hidden; animation: rise .35s var(--ease);
}
.modal-head {
  flex: none; display: flex; align-items: center; gap: 14px;
  padding: 14px 16px 14px 26px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 22px; font-weight: 850; letter-spacing: -.03em; white-space: nowrap; }
.modal-tabs { flex: 1; display: flex; gap: 6px; overflow-x: auto; }
.modal-tab {
  height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line2);
  background: transparent; font-size: 14px; font-weight: 700; color: var(--mute); cursor: pointer; white-space: nowrap;
}
.modal-tab.on { background: var(--paper); color: var(--bg); border-color: var(--paper); }
.modal-actions { display: flex; gap: 8px; }
.modal-x {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line2);
  background: transparent; font-size: 18px; cursor: pointer;
}
.modal-x:hover { background: var(--bg3); }
.modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 26px 30px 36px; }

/* 기획안 */
.plan-pages { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.plan-pages figure { margin: 0; border-radius: 12px; overflow: hidden; background: #fff; }
.plan-pages img { display: block; width: 100%; height: auto; }
.plan-pages figcaption { padding: 8px 12px; font-size: 13px; color: #444; background: #f3f1ec; }

/* 편지 */
.letter {
  max-width: 720px; margin: 0 auto; padding: 44px 52px 48px;
  border-radius: 6px; background: var(--paper); color: #1d1f24;
  font-size: 19px; line-height: 1.85;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.8);
}
.letter .to { font-weight: 800; font-size: 21px; margin-bottom: 18px; }
.letter p + p { margin-top: 14px; }
.letter .from { margin-top: 26px; text-align: right; color: #5b5e66; font-size: 16px; }
.letter .mine { margin: 18px 0; padding: 14px 18px; border-left: 3px solid #1d1f24; background: rgba(0,0,0,.04); font-size: 17px; line-height: 1.7; }
.letter .mine li { margin: 2px 0; }
.letter ul { margin: 0; padding-left: 20px; }
.letter .hint { margin: 18px 0; padding: 14px 18px; border-left: 3px solid #E0532F; background: rgba(224,83,47,.06); font-size: 17px; line-height: 1.7; }
.letter .hint .h { margin-top: 8px; }
.letter .hint .h::before { content: "· "; font-weight: 800; }

/* ── 토스트 ──────────────────────────────────── */
.toast {
  position: fixed; left: 50%; top: 92px; z-index: 80; transform: translateX(-50%);
  padding: 10px 20px; border-radius: 999px;
  background: var(--paper); color: var(--bg); font-size: 18px; font-weight: 800;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  animation: toast 1.1s var(--ease) forwards;
  pointer-events: none;
}
.toast.bad { background: var(--bad); color: #fff; }
.toast.good { background: var(--glow); color: var(--bg); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -8px); }
  15%, 75% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -6px); }
}

/* ── 작은 화면 (크롬북 1366×768 이하) ───────── */
@media (max-height: 720px) {
  .topbar { height: 56px; }
  .home { padding: 16px 24px 16px; gap: 14px; }
  .home-head h1 { font-size: 34px; }
  .poster-info { padding: 14px 18px 16px; }
  .poster-info h2 { font-size: 26px; }
  .poster-meta { margin-top: 10px; }
  .teams { padding: 8px 12px; }
  .team { height: 38px; }
  .gbar { height: 64px; }
  .overlay { top: 64px; }
}
@media (max-width: 1180px) {
  .gtitle h2 { font-size: 19px; }
  .tbtn { padding: 0 12px; font-size: 14px; }
}
