/* ==========================================================================
   Ular Tangga - Luxury Tactile Minimalist Board Game
   Design: Ceramic Tile Grid, Ambient Drop Shadows & Tactile Physics
   ========================================================================== */

:root {
  --bg-page: #f5f7fa;
  --bg-board: #f1f5f9;
  --bg-tile: #ffffff;
  --bg-tile-alt: #f8fafc;
  
  --border-subtle: #e2e8f0;
  --border-card: #e2e8f0;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --p1-color: #0f172a;
  --p2-color: #e11d48;

  --ladder-accent: #059669;
  --snake-accent: #e11d48;
  --challenge-accent: #d97706;

  --radius-board: 20px;
  --radius-tile: 8px;
  --radius-sm: 6px;

  --shadow-board: 0 1px 3px rgba(0,0,0,0.04), 0 16px 36px -6px rgba(15, 23, 42, 0.08);
  --shadow-tile: 0 1px 3px rgba(0,0,0,0.03);
  --shadow-token: 0 4px 10px rgba(0,0,0,0.22);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 12px 60px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-y: auto;
}

.app-wrap {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* TOPBAR */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-chip {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.room-chip strong {
  color: var(--text-main);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* LOBBY CARD */
.card {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-board);
  box-shadow: var(--shadow-board);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.view-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.lobby-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 2px 0;
}

/* FORM CONTROLS */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}

.input-field {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: all 150ms ease;
}

.input-field:focus {
  border-color: var(--text-main);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}

.input-sm {
  padding: 7px 10px;
  font-size: 0.85rem;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 140ms ease;
  width: 100%;
}

.btn-primary {
  background: var(--text-main);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.14);
}

.btn-primary:hover:not(:disabled) {
  background: #1e293b;
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover:not(:disabled) {
  background: #e2e8f0;
}

.btn-sm {
  width: auto;
  padding: 7px 14px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 4px;
}

.btn-text:hover {
  color: #ef4444;
}

/* LOBBY CREATED BOX */
.created-box {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.created-title {
  font-size: 0.85rem;
  font-weight: 500;
}

.share-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-badge {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 4px 12px;
  border-radius: 4px;
  color: var(--text-main);
  box-shadow: var(--shadow-tile);
}

.wait-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

.counter-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-counter {
  width: 44px;
  height: 42px;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  user-select: none;
  border-radius: var(--radius-sm);
}

.input-counter {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
  max-width: 120px;
  cursor: default;
}

/* ==========================================================================
   SETUP VIEW (DEDICATED CHALLENGE INPUT SCREEN)
   ========================================================================== */
.setup-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}

.setup-header-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  color: var(--text-muted);
}

.setup-count-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  color: var(--text-main);
}

.setup-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.challenge-inputs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0 16px;
}

.challenge-input-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.card-tier-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tier-label-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

.tier-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 4px;
}

.tier-badge-mudah {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.tier-badge-sedang {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}

.tier-badge-susah {
  background: #fff1f2;
  color: #e11d48;
  border: 1px solid #fecdd3;
}

.tier-zone-hint {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.setup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==========================================================================
   GAME ARENA (LUXURY MINIMALIST ELEVATION)
   ========================================================================== */

/* PLAYERS BAR */
.players-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-tile);
  padding: 10px 14px;
  box-shadow: var(--shadow-tile);
}

.player-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 180ms ease;
}

.player-pill.player-2 {
  justify-content: flex-end;
}

.player-pill.active-turn {
  background: var(--bg-subtle);
  box-shadow: inset 0 0 0 1px var(--border-subtle);
}

.token-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: var(--shadow-token);
}

.token-p1 {
  background: radial-gradient(circle at 35% 35%, #334155, var(--p1-color));
}

.token-p2 {
  background: radial-gradient(circle at 35% 35%, #fb7185, var(--p2-color));
}

.player-meta {
  display: flex;
  flex-direction: column;
}

.text-right {
  text-align: right;
}

.player-name {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.2;
}

.player-pos {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 500;
}

.turn-dot {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: #0f172a;
  color: #ffffff;
  letter-spacing: 0.05em;
}

.players-divider {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-light);
}

/* CERAMIC BOARD TRAY (6x6) */
.board-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-board);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-board);
  box-shadow: var(--shadow-board);
  padding: 7px;
  overflow: hidden;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 5px;
  width: 100%;
  height: 100%;
}

.board-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px 6px;
  border-radius: var(--radius-tile);
  border: 1px solid rgba(226, 232, 240, 0.75);
  box-shadow: var(--shadow-tile);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.cell-even {
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
}

.cell-odd {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.cell-num {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: #475569;
  line-height: 1;
  position: relative;
  z-index: 6;
}

.cell-tag, .trap-owner-badge {
  position: relative;
  z-index: 6;
}

.cell-tag {
  font-size: 0.62rem;
  font-weight: 800;
  align-self: flex-end;
  line-height: 1;
  letter-spacing: 0.03em;
}

.cell-start {
  background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%) !important;
  border-color: rgba(16, 185, 129, 0.35);
}

.cell-start .cell-tag {
  color: var(--ladder-accent);
}

.cell-finish {
  background: linear-gradient(180deg, #fefce8 0%, #fef08a 100%) !important;
  border-color: rgba(234, 179, 8, 0.4);
}

.cell-finish .cell-tag {
  color: #a16207;
}

.cell-challenge {
  background: linear-gradient(180deg, #fffbeb 0%, #fde68a 100%) !important;
  border-color: rgba(245, 158, 11, 0.45);
}

.cell-challenge .cell-tag {
  color: #b45309;
}

/* SECRET MINE / TRAP INDICATORS */
.label-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 4px;
}

.cell-my-trap {
  border: 1.5px dashed #94a3b8 !important;
}

.trap-owner-badge {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 1px 4px;
  border-radius: 3px;
  align-self: flex-end;
  letter-spacing: 0.02em;
}

.cell-trap-triggered {
  animation: trapReveal 350ms ease;
  background: #fef2f2 !important;
  border-color: #f87171 !important;
}

@keyframes trapReveal {
  0% { transform: scale(0.96); }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* SVG CONNECTOR OVERLAY (LADDERS & SNAKES) */
.board-svg-overlay {
  position: absolute;
  inset: 7px;
  width: calc(100% - 14px);
  height: calc(100% - 14px);
  pointer-events: none;
  z-index: 5;
  opacity: 0.95;
}

/* PION PIECES (3D TACTILE PEBBLES) */
.token-piece {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: transform 220ms cubic-bezier(0.34, 1.4, 0.64, 1), left 220ms ease, top 220ms ease;
}

.piece-p1 {
  background: radial-gradient(circle at 35% 35%, #475569 0%, var(--p1-color) 70%);
}

.piece-p2 {
  background: radial-gradient(circle at 35% 35%, #fb7185 0%, var(--p2-color) 70%);
}

.token-inner {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Hop Physics Animation */
.token-piece.hop {
  transform: scale(1.35) translateY(-10px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
}

/* DICE CONTROLS */
.dice-section {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-tile);
  padding: 12px 16px;
  box-shadow: var(--shadow-tile);
}

.dice-display {
  width: 58px;
  height: 58px;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-tile);
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 500px;
}

.dice-cube {
  width: 44px;
  height: 44px;
  background: linear-gradient(145deg, #ffffff, #f1f5f9);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1), inset 0 1px 1px #ffffff;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 5px;
  transition: transform 400ms cubic-bezier(0.34, 1.3, 0.64, 1);
}

.dice-cube.rolling {
  animation: dice-tumble 450ms ease-in-out;
}

@keyframes dice-tumble {
  0% { transform: rotate(0deg) scale(0.9); }
  25% { transform: rotate(-45deg) scale(1.1); }
  50% { transform: rotate(90deg) scale(0.85); }
  75% { transform: rotate(-180deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}

.dice-dot {
  width: 7px;
  height: 7px;
  background: #0f172a;
  border-radius: 50%;
  margin: auto;
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.3);
}

.dice-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.turn-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-roll {
  padding: 10px 18px;
  font-size: 0.95rem;
}

/* CHALLENGE MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
}

.modal-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-board);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  width: 100%;
  max-width: 380px;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  animation: modal-pop 200ms cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes modal-pop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  color: var(--text-muted);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.modal-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.challenge-quote {
  background: var(--bg-page);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  width: 100%;
  line-height: 1.5;
}

/* TOAST NOTIFIKASI */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  z-index: 99999;
  transition: opacity 160ms ease;
}

.hidden {
  display: none !important;
}
