:root {
  --bg: #0e1a24;
  --panel: #152636;
  --ink: #e8f1f6;
  --muted: #8aa0b2;
  --accent: #f0c75e;
  --ok: #5ddea8;
  --line: rgba(255, 255, 255, 0.08);
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #050a10;
  color: var(--ink);
}

/* Desktop: show phone bezel preview */
.phone-frame {
  width: min(390px, 100%);
  margin: 16px auto;
  background: #111;
  border: 10px solid #1a1f26;
  border-radius: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 780px;
  max-height: 844px;
  background:
    radial-gradient(500px 280px at 20% -10%, #1c3a4f 0%, transparent 55%),
    var(--bg);
  padding: 10px 10px 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.brand {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.hud {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.pos-toast {
  color: var(--accent);
  font-weight: 700;
}

/* Goal banner: picture + full sentence always visible */
.goal-banner {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  flex-shrink: 0;
  margin-bottom: 8px;
}

#goalArt {
  width: 88px;
  height: 88px;
  background: #dfe9ef;
  border-radius: 8px;
  display: block;
}

.goal-copy {
  min-width: 0;
}

.goal-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.goal-sentence {
  margin: 4px 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

/* 완성 문장: 조사만 색 유지, 나머지는 기본색 */
.goal-sentence .tok {
  color: var(--ink);
}

.goal-sentence .tok.pos-particle {
  color: #7ec8ff;
}

.goal-sentence .tok.cling {
  margin-left: 0;
}

.pos-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
}

.pos-legend span::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

.pos-legend .leg-noun::before {
  background: #5ddea8;
}

.pos-legend .leg-particle::before {
  background: #7ec8ff;
}

.pos-legend .leg-predicate::before {
  background: #f0c75e;
}

.goal-hint {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 8px;
}

#game {
  width: 100%;
  height: 100%;
  min-height: 280px;
  display: block;
  background: #071018;
  border: 1px solid var(--line);
  border-radius: 10px;
  touch-action: none;
}

.sentence-bar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px 12px;
  flex-shrink: 0;
}

.sentence-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.sentence {
  font-size: 22px;
  letter-spacing: 0.04em;
  min-height: 1.4em;
  text-align: center;
}

.sentence .slot {
  display: inline-block;
  min-width: 1.6em;
  text-align: center;
  border-bottom: 2px solid var(--muted);
  color: var(--muted);
  margin: 0;
  margin-left: 0.42em; /* 어절 사이는 넓게 */
}

.sentence .slot:first-child {
  margin-left: 0;
}

/* 조사: 앞말과의 간격만 좁혀 "붙어 나온다"는 느낌 */
.sentence .slot.cling {
  margin-left: 0.06em;
  min-width: 1.15em;
}

.sentence .joiner {
  display: inline-block;
  color: var(--muted);
}

.sentence .joiner.gap {
  min-width: 0.35em;
}

.sentence .joiner.end {
  margin-left: 0.06em;
}

.sentence .slot.filled {
  font-weight: 700;
}

.sentence .slot.filled.pos-noun {
  color: #5ddea8;
  border-bottom-color: #5ddea8;
}

.sentence .slot.filled.pos-particle {
  color: #7ec8ff;
  border-bottom-color: #7ec8ff;
}

.sentence .slot.filled.pos-predicate {
  color: #f0c75e;
  border-bottom-color: #f0c75e;
}

.sentence .slot.flash {
  filter: brightness(1.25);
}

.touch-pad {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.pad-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #1c2d3d;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  border-radius: 12px;
  min-height: 52px;
  cursor: pointer;
  user-select: none;
}

.pad-btn:active,
.pad-btn.held {
  background: #2a455c;
}

.pad-btn.fire {
  background: var(--accent);
  color: #1a1406;
  font-size: 16px;
}

.pad-btn.fire:active,
.pad-btn.fire.held {
  filter: brightness(1.08);
}

.help {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.desktop-only {
  display: none;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 16, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.overlay[hidden] {
  display: none;
}

.card {
  width: min(360px, 100%);
  background: #132333;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px 20px;
  text-align: center;
}

.card h1 {
  margin: 0 0 10px;
  font-size: 24px;
}

.card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-line;
}

.card button {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #1a1406;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
}

/* Real phone: full bleed, no bezel chrome */
@media (max-width: 480px) {
  body {
    background: var(--bg);
  }

  .phone-frame {
    width: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    min-height: 100dvh;
  }

  #app {
    min-height: 100dvh;
    max-height: none;
    padding:
      max(8px, env(safe-area-inset-top))
      10px
      max(10px, env(safe-area-inset-bottom));
  }
}

/* Wide desktop: keep phone preview centered, show keyboard hint */
@media (min-width: 720px) {
  .desktop-only {
    display: block;
  }

  body {
    background:
      radial-gradient(900px 500px at 50% 0%, #1a3040 0%, transparent 50%),
      #050a10;
    padding: 12px 0 32px;
  }
}
