:root {
  --bg: #07070c;
  --panel: rgba(12, 12, 20, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #f43f5e;
  --accent2: #fbbf24;
  --ok: #22c55e;
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  overflow: hidden;
}

#app {
  height: 100%;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.panel {
  height: 100%;
  overflow: auto;
  padding: 16px 14px 28px;
  background: radial-gradient(ellipse at top, #1a1030 0%, #07070c 55%);
}

.brand h1 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, #fbbf24, #f43f5e, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

.field input {
  background: #0b1220;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 12px;
  font-size: 1rem;
}

.subhead {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 8px 0;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.char-card {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid transparent;
  background: #111827;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px;
}

.char-card.selected {
  border-color: var(--accent2);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.35);
}

.char-card .mini-portrait {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.char-card .nm {
  font-size: 0.58rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.1;
}

.char-card .nm-role {
  font-size: 0.55rem;
  color: var(--accent2);
  text-align: center;
  line-height: 1.1;
}

.char-portrait {
  border-radius: 50%;
  flex-shrink: 0;
}

.char-detail-head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.char-detail .jp {
  color: var(--accent2);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
}

.jp-sub {
  color: var(--accent2);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  margin: 4px 0 8px;
  font-size: 1.1rem;
}

.scoreboard {
  margin: 12px 0;
  text-align: left;
  font-size: 0.85rem;
}

.score-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}

#controls.dimmed {
  opacity: 0.25;
  pointer-events: none;
}

#overlay .btn {
  margin-top: 12px;
  min-width: 160px;
  pointer-events: auto;
}

.char-detail {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  min-height: 92px;
  font-size: 0.85rem;
}

.char-detail h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.char-detail .role {
  color: var(--accent2);
  font-size: 0.75rem;
  margin-bottom: 6px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 0.75rem;
}

.lobby-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 14px 12px;
  font-weight: 700;
  font-size: 0.95rem;
  background: #1e293b;
  color: var(--text);
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, #e11d48, #f59e0b);
  color: #fff;
}

.msg {
  min-height: 1.2em;
  color: #fca5a5;
  font-size: 0.8rem;
  margin: 8px 0;
}

.roster {
  display: grid;
  gap: 6px;
}

.roster-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  font-size: 0.85rem;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.hidden {
  display: none !important;
}

#game-root {
  position: absolute;
  inset: 0;
  background: #000;
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: 8px 10px;
  pointer-events: none;
}

#hud-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-shadow: 0 1px 2px #000;
}

#hud-party {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 6px;
}

.party-chip {
  background: rgba(0, 0, 0, 0.45);
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 0.65rem;
}

.party-chip .bar {
  height: 4px;
  background: #333;
  border-radius: 2px;
  margin-top: 3px;
  overflow: hidden;
}

.party-chip .bar > i {
  display: block;
  height: 100%;
  background: #22c55e;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 20;
}

#overlay.interactive {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.72);
}

#overlay .banner {
  text-align: center;
  padding: 18px 22px;
  border-radius: 16px;
  background: rgba(10, 10, 18, 0.9);
  border: 1px solid var(--line);
}

#overlay .banner h2 {
  margin: 0 0 6px;
  font-size: 1.4rem;
}

#controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
}

.stick {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  position: relative;
  pointer-events: auto;
  touch-action: none;
}

.stick-knob {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.action-btns {
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}

.act {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  font-weight: 800;
  font-size: 0.75rem;
  color: #fff;
  pointer-events: auto;
  touch-action: none;
}

.act.attack {
  background: radial-gradient(circle at 30% 30%, #fb7185, #be123c 70%);
}

.act.skill {
  background: radial-gradient(circle at 30% 30%, #fde68a, #b45309 70%);
  width: 60px;
  height: 60px;
  align-self: flex-end;
}

.act:active {
  transform: scale(0.96);
}
