:root {
  --bg0: #0f241c;
  --bg1: #163528;
  --bg2: #1e4635;
  --panel: rgba(255, 248, 235, 0.94);
  --ink: #14241c;
  --muted: #5a6e63;
  --accent: #e85d04;
  --accent2: #2a9d8f;
  --line: rgba(20, 36, 28, 0.12);
  --ok: #2a9d8f;
  --bad: #c1121f;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: "IBM Plex Sans KR", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, #2d6a4f 0%, transparent 55%),
    linear-gradient(160deg, #081510 0%, #143528 40%, #0b1c16 100%);
}

body {
  display: grid;
  place-items: center;
  padding: 18px 12px 28px;
}

.phone {
  width: min(430px, 100%);
  min-height: min(860px, calc(100vh - 36px));
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), transparent 28%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.top {
  padding: 18px 18px 10px;
  color: #f4fff8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bgm-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  background: rgba(0,0,0,0.22);
  color: #ffd166;
  font-size: 1.05rem;
  cursor: pointer;
  line-height: 1;
}
.bgm-btn.muted {
  color: rgba(244,255,248,0.45);
  text-decoration: line-through;
}

.hud {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.85rem;
  gap: 2px;
}
.point { color: #ffd166; font-weight: 700; }

.app {
  flex: 1;
  overflow: auto;
  padding: 8px 14px 18px;
}

.nav {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 10px 6px 14px;
  background: rgba(0,0,0,0.28);
  border-top: 1px solid rgba(255,255,255,0.06);
}
.nav button {
  border: 0;
  background: transparent;
  color: rgba(244,255,248,0.55);
  font: inherit;
  font-size: 0.64rem;
  font-weight: 600;
  padding: 10px 0;
  border-radius: 12px;
  cursor: pointer;
}
.nav button.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.panel {
  background: var(--panel);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
}
.panel h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}
.panel p, .muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.stack { display: grid; gap: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }

label.field {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

button.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent2);
  color: #fff;
}
button.btn.secondary { background: #264653; }
button.btn.accent { background: var(--accent); }
button.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.choice-grid button {
  padding: 16px 8px;
  font-size: 1.05rem;
}

.log {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #10241c;
  color: #d8f3dc;
  border: 1px solid rgba(216,243,220,0.14);
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 88px;
  white-space: pre-wrap;
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 12px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}
.log.empty { color: rgba(216,243,220,0.45); }

.log.flash {
  animation: logFlash 0.6s ease-out;
}
@keyframes logFlash {
  0% { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,93,4,0.35); }
  100% { border-color: rgba(216,243,220,0.14); box-shadow: 0 10px 20px rgba(0,0,0,0.4); }
}

.bet-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
button.btn.chip {
  flex: 1;
  min-width: 56px;
  padding: 9px 6px;
  font-size: 0.82rem;
  background: #264653;
}
button.btn.chip.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.list {
  display: grid;
  gap: 8px;
}
.item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 0.9rem;
}
.item .meta { color: var(--muted); font-size: 0.8rem; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(42,157,143,0.15);
  color: #1d6f66;
  font-size: 0.75rem;
  font-weight: 700;
}

.auth-hero {
  color: #f4fff8;
  padding: 18px 8px 8px;
  text-align: center;
}
.auth-hero h1 {
  margin: 0 0 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 2rem;
  letter-spacing: -0.04em;
}
.auth-hero p {
  margin: 0;
  opacity: 0.78;
  line-height: 1.5;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.tabs button {
  border: 0;
  background: rgba(0,0,0,0.06);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.tabs button.active { background: var(--accent2); color: #fff; }

.hidden { display: none !important; }
.err { color: var(--bad); font-size: 0.85rem; margin-top: 6px; }
.center { text-align: center; }

.game-card {
  width: 100%;
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  align-items: center;
  text-align: left;
  border: 0;
  background: var(--panel);
  border-radius: 18px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.game-card-icon {
  width: 88px;
  height: 72px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  background: #10241c;
  color: #ffd166;
}

.pet-card { text-align: center; }
.pet-emoji {
  font-size: 4.2rem;
  line-height: 1;
  margin: 6px 0 10px;
}
.pet-name { margin: 0 0 12px; color: var(--muted); }
.pet-name b { color: var(--ink); }

.stat-title {
  margin: 8px 0 0;
  font-size: 0.95rem;
}
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
  text-align: left;
}
.stat-item {
  background: rgba(16, 36, 28, 0.06);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.88rem;
}
.stat-item span { color: var(--muted); }
.stat-item b { color: var(--ink); }

.avatar-stage {
  min-height: 150px;
  border-radius: 18px;
  background: radial-gradient(circle at 50% 45%, #d8f3dc, #95d5b2 55%, #40916c);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  overflow: hidden;
}
.avatar-base { font-size: 4.8rem; line-height: 1; filter: drop-shadow(0 5px 5px rgba(0,0,0,.2)); }
.avatar-equipment {
  min-height: 32px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  font-size: 1.35rem;
}
.equip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.equip-slot {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: 72px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.equip-slot .btn { grid-column: 1 / -1; padding: 7px; }
.equip-slot.empty { opacity: .68; }
.slot-icon { font-size: 1.45rem; }
.bag-item {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.bag-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.bag-actions .btn { padding: 7px 9px; font-size: .78rem; }

.sword-stage {
  padding: 25px 14px;
  border-radius: 18px;
  text-align: center;
  background: radial-gradient(circle, #fff3bf, #e85d04 75%, #6a040f);
}
.sword-stage h2 { margin: 10px 0 4px; color: #3d1404; }
.sword-icon { font-size: 5rem; filter: grayscale(1); }
.sword-icon.active {
  filter: drop-shadow(0 0 12px #fff3bf);
  animation: swordGlow 1.2s ease-in-out infinite alternate;
}
@keyframes swordGlow {
  from { transform: scale(1) rotate(-3deg); }
  to { transform: scale(1.08) rotate(3deg); }
}

.mine-stage {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 24px 12px;
  background: rgba(255,248,235,0.95);
}
.mine-visual {
  font-size: 4rem;
  line-height: 1;
}
.mine-stage.swing .mine-visual {
  animation: mineSwing 0.35s ease-in-out;
}
@keyframes mineSwing {
  0% { transform: rotate(0deg); }
  40% { transform: rotate(-25deg) scale(1.08); }
  100% { transform: rotate(0deg); }
}
.game-card strong { display: block; font-size: 1.05rem; }
.game-card span { color: var(--muted); font-size: 0.85rem; }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(8, 20, 16, 0.72);
  display: flex;
  flex-direction: column;
}
.overlay.hidden { display: none !important; }
.sheet {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 48px;
  background: linear-gradient(180deg, #163528, #0f241c);
  border-radius: 22px 22px 0 0;
  overflow: hidden;
}
.sheet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  color: #f4fff8;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sheet-top .back { padding: 8px 10px; color: #f4fff8; border-color: rgba(255,255,255,0.2); }
.sheet-body {
  flex: 1;
  overflow: auto;
  padding: 14px;
  background: transparent;
}
.sheet-body.stack {
  grid-auto-rows: max-content;
  align-content: start;
}
.sheet-body .field { color: rgba(244,255,248,0.7); }
.sheet-body input, .sheet-body select {
  background: rgba(255,255,255,0.95);
}

.stage-art {
  border-radius: 16px;
  overflow: hidden;
  background: #0b1c16;
  margin-bottom: 4px;
}
.stage-art img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
}
.fish-stage { position: relative; }
.fish-stage.casting img { animation: castBob 0.45s ease-in-out infinite alternate; }
@keyframes castBob {
  from { transform: translateY(0); }
  to { transform: translateY(6px) scale(1.02); }
}
.fish-splash {
  position: absolute;
  left: 55%;
  top: 55%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(120, 220, 255, 0.7);
  opacity: 0;
  pointer-events: none;
}
.fish-splash.show { animation: splash 1s ease-out; }
@keyframes splash {
  0% { transform: scale(0.4); opacity: 0.9; }
  100% { transform: scale(4); opacity: 0; }
}

.arena {
  display: grid;
  grid-template-columns: 1fr 72px 1fr;
  gap: 6px;
  align-items: center;
  background: rgba(255,248,235,0.95);
  border-radius: 16px;
  padding: 12px 8px;
}
.arena.shaking .hand { animation: shakeHand 0.12s linear infinite; }
@keyframes shakeHand {
  0%, 100% { transform: rotate(-12deg); }
  50% { transform: rotate(12deg); }
}
.arena-side { text-align: center; }
.arena-label {
  font-size: 0.75rem;
  font-weight: 700;
  background: #ffd6a5;
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 8px;
}
.arena-label.me { background: #a8dadc; }
.hand { font-size: 2.6rem; line-height: 1.2; min-height: 52px; }
.hand-name { font-weight: 700; font-size: 0.9rem; }
.result-badge {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: #fff;
  border: 3px solid #2a9d8f;
}
.result-badge.win { background: #d8f3dc; border-color: #2a9d8f; color: #1b4332; }
.result-badge.lose { background: #ffccd5; border-color: #c1121f; color: #6a040f; }
.result-badge.draw { background: #fff3bf; border-color: #e85d04; color: #9a3412; }
.result-badge.pop, .die.pop { animation: popIn 0.35s ease-out; }
@keyframes popIn {
  0% { transform: scale(0.6); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.result-panel {
  background: #10241c;
  color: #d8f3dc;
  border-radius: 14px;
  padding: 14px;
  min-height: 96px;
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.5;
  border: 1px solid rgba(216,243,220,0.18);
  box-shadow: 0 0 0 2px rgba(232,93,4,0.15);
}

.dice-board {
  display: flex;
  justify-content: center;
  gap: 12px;
  background: rgba(255,248,235,0.95);
  border-radius: 16px;
  padding: 18px 12px;
}
.die {
  font-size: 2.8rem;
  display: inline-block;
  min-width: 1.2em;
  text-align: center;
}
.dice-board.spinning .die { animation: dieSpin 0.15s linear infinite; }
@keyframes dieSpin {
  from { transform: translateY(-4px); }
  to { transform: translateY(4px); }
}

button.btn.big { padding: 16px; font-size: 1.05rem; }

.chat-box {
  background: #10241c;
  color: #d8f3dc;
  border-radius: 14px;
  padding: 12px;
  height: 360px;
  overflow: auto;
  margin-bottom: 10px;
}
.chat-msg { margin-bottom: 8px; font-size: 0.9rem; line-height: 1.4; }
.chat-msg b { color: #ffd166; margin-right: 6px; }
.chat-sys {
  text-align: center;
  color: rgba(216,243,220,0.6);
  font-size: 0.8rem;
  margin: 10px 0;
}
.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.chat-form input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
}

.toast {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 84px;
  z-index: 40;
  background: rgba(20, 36, 28, 0.94);
  color: #f4fff8;
  border-radius: 14px;
  padding: 12px 14px;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 0.25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 480px) {
  body { padding: 0; }
  .phone {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
    border: 0;
  }
}
