:root {
  color-scheme: light dark;
  --bg: #0f1115;
  --surface: #171a21;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #7c9cff;
  --danger: #ff7b7b;
  --ok: #5fd39a;
  --border: #2a3140;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.start-wrap {
  max-width: 24rem;
  margin: auto;
  padding: 1.5rem;
  text-align: center;
}

.title {
  font-size: 1.75rem;
  margin: 0 0 0.25rem;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: left;
  margin-bottom: 1.25rem;
  color: var(--muted);
}

.select {
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.btn {
  font: inherit;
  padding: 0.65rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-height: 44px;
}

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

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #0b0d12;
  font-weight: 600;
  width: 100%;
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
}

.play-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(15, 17, 21, 0.96);
  backdrop-filter: blur(8px);
  z-index: 2;
}

.play-header--minimal {
  justify-content: center;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
}

.play-main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.play-main--active {
  padding-bottom: 10rem;
}

.play-main--over {
  padding: 0.75rem 1rem 9rem;
}

.game-over-hero {
  text-align: center;
  margin-bottom: 1.25rem;
}

.game-over-title {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
}

.game-over-title--win {
  color: var(--ok);
}

.game-over-title--lose {
  color: var(--danger);
}

.game-over-sub {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.reveal-all {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.reveal-row-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

.reveal-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.play-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  background: rgba(15, 17, 21, 0.98);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.play-footer__primary {
  padding: 0.75rem 1rem;
}

.btn-new-game {
  width: 100%;
}

.play-footer__actions {
  padding: 0.65rem 1rem 0.4rem;
}

.help-dock {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem 0.65rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.22);
}

.help-dock__btn {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  min-height: 36px;
  border-radius: 0.45rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.help-dock__btn:active {
  background: var(--surface);
  color: var(--text);
}

.status {
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
}

.ai-banner {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  color: var(--accent);
  background: rgba(124, 156, 255, 0.12);
  border-bottom: 1px solid var(--border);
}

.steal-reveal {
  margin: 0 1rem 0.75rem;
  padding: 0.75rem;
  border-radius: 0.65rem;
  border: 1px solid var(--ok);
  background: rgba(95, 211, 154, 0.12);
}

.steal-reveal-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.steal-reveal-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.pick-steal {
  margin: 0 1rem 0.75rem;
  padding: 0.75rem;
  border-radius: 0.65rem;
  border: 1px solid var(--accent);
  background: rgba(124, 156, 255, 0.08);
}

.pick-steal-heading {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
}

.pick-steal-note {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.pick-card-num {
  position: absolute;
  top: 0.2rem;
  left: 0.25rem;
  z-index: 2;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 0 4px var(--bg);
  pointer-events: none;
}

.pick-steal-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.pick-card {
  position: relative;
  border: none;
  padding: 0;
  border-radius: 0.5rem;
  background: transparent;
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 3px;
}

.pick-card--on {
  outline-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 156, 255, 0.5);
}

.pick-steal-actions {
  justify-content: center;
}

.continue-row {
  width: 100%;
  justify-content: center;
  margin-bottom: 0.35rem;
}

.opponents-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.opponents {
  display: flex;
  gap: 0.5rem;
}

.opp {
  flex: 0 0 auto;
  min-width: 7.5rem;
  padding: 0.5rem;
  border-radius: 0.65rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.opp--on {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(124, 156, 255, 0.35);
}

.opp--off {
  opacity: 0.55;
  cursor: not-allowed;
}

/* AI 차례일 때 행동 중인 AI 상대 패널 강조 */
.opp--current-turn {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px rgba(124, 156, 255, 0.55),
    0 0 14px rgba(124, 156, 255, 0.35);
}

.opp--off.opp--current-turn {
  opacity: 1;
}

/* 탈취 위치 고르기 중 지목된 상대 손패 영역 */
.opp--steal-victim {
  outline: 2px solid rgba(230, 180, 80, 0.95);
  outline-offset: 2px;
  border-color: rgba(200, 160, 70, 0.85);
  box-shadow:
    0 0 0 1px rgba(230, 180, 80, 0.45),
    0 0 12px rgba(230, 180, 80, 0.28);
}

.opp--off.opp--steal-victim {
  opacity: 1;
}

.opp-hand-block {
  margin-bottom: 0.35rem;
}

.opp-hand-block .opp-hand {
  margin-bottom: 0;
}

.opp-hand-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.2rem;
}

.opp-hand-badge {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.14rem 0.4rem;
  border-radius: 0.3rem;
  line-height: 1.2;
}

.opp-hand-badge--turn {
  background: linear-gradient(180deg, rgba(124, 156, 255, 0.95), rgba(90, 120, 220, 0.95));
  color: #0b0e14;
}

.opp-hand-badge--victim {
  background: linear-gradient(180deg, rgba(230, 190, 100, 0.95), rgba(180, 130, 50, 0.95));
  color: #0b0e14;
}

.opp-hand {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.opp-count {
  font-size: 0.85rem;
  color: var(--muted);
}

.opp-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.opp-name {
  font-weight: 600;
}

.my-area {
  flex: 1;
  padding: 0.75rem 1rem 1rem;
  overflow: visible;
}

.my-area--active-turn .section-title {
  color: var(--text);
}

.hand-turn-badge {
  display: inline-block;
  margin-left: 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 0.35rem;
  vertical-align: middle;
  background: linear-gradient(180deg, rgba(124, 156, 255, 0.95), rgba(90, 120, 220, 0.95));
  color: #0b0e14;
}

.my-hand--turn-active {
  padding: 0.45rem 0.5rem;
  border-radius: 0.65rem;
  outline: 2px solid var(--accent);
  outline-offset: 0;
  box-shadow:
    0 0 0 1px rgba(124, 156, 255, 0.45),
    0 0 14px rgba(124, 156, 255, 0.22);
}

.my-area--steal-mark .section-title {
  color: var(--text);
}

.hand-steal-badge {
  display: inline-block;
  margin-left: 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 0.35rem;
  vertical-align: middle;
  background: linear-gradient(180deg, rgba(230, 190, 100, 0.95), rgba(180, 130, 50, 0.95));
  color: #0b0e14;
}

.my-hand--steal-mark {
  padding: 0.45rem 0.5rem;
  border-radius: 0.65rem;
  outline: 2px solid rgba(230, 180, 80, 0.95);
  outline-offset: 0;
  box-shadow:
    0 0 0 1px rgba(230, 180, 80, 0.45),
    0 0 12px rgba(230, 180, 80, 0.22);
}

.victim-pick-row {
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-weight: 600;
}

.my-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.my-card {
  border: none;
  padding: 0;
  background: transparent;
  border-radius: 0.5rem;
  cursor: default;
}

.my-card--pickable {
  cursor: pointer;
  outline: 2px solid var(--ok);
  outline-offset: 2px;
}

.card {
  position: relative;
  width: 4.5rem;
  height: 6.75rem;
  border-radius: 0.45rem;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #1b2030;
}

.card--sm {
  width: 2.75rem;
  height: 4.125rem;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  background: #252a38;
}

.card.card--fallback .card-fallback {
  display: flex;
}

.card--back.card--fallback {
  background: linear-gradient(135deg, #2a3144, #151822);
}

.action-bar-inner {
  width: 100%;
}

.hint {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.row.wrap {
  justify-content: center;
}

.sheet[hidden] {
  display: none !important;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 78dvh;
  background: var(--surface);
  border-radius: 1rem 1rem 0 0;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sheet-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.sheet-body {
  padding: 1rem;
  overflow: auto;
}

.rules-list {
  margin: 0;
  padding-left: 1.1rem;
}

.rules-list li {
  margin-bottom: 0.5rem;
}

.log p {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

@media (min-width: 720px) {
  .card {
    width: 5rem;
    height: 7.5rem;
  }

  .opponents {
    flex-wrap: wrap;
  }
}
