/* ===== Ludo King — Authentic Styling ===== */
:root {
  --red: #DE2327;
  --red-dark: #990000;
  --green: #009A44;
  --green-dark: #006020;
  --yellow: #FED100;
  --yellow-dark: #C69200;
  --blue: #009FE3;
  --blue-dark: #006699;
  --gold: #FFD100;
  --gold-dark: #C69200;
  --bg-dark: #071936;
  --bg-mid: #0D3468;
  --bg-light: #154D96;
  --card-bg: rgba(7, 25, 54, 0.85);
  --text: #ffffff;
  --text-muted: #9BB3D6;
  --shadow: rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "Baloo 2", system-ui, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  user-select: none;
}

/* Authentic Ludo King Blue Tiled Pattern Background */
#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background-color: #08234b;
  background-image:
    linear-gradient(180deg, rgba(2, 17, 43, 0.20), rgba(2, 15, 37, 0.48)),
    url("assets/ui/ludo-tile-background.png");
  background-position: center, center;
  background-size: cover, cover;
  background-repeat: no-repeat, no-repeat;
  overflow: hidden;
}

/* ===== SCREENS ===== */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
.screen.active { display: flex; }

/* ===== HOME SCREEN ===== */
.home {
  justify-content: center;
  align-items: center;
  padding: 30px 20px;
  gap: 22px;
}

/* particles */
.particles {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.particles .dot {
  position: absolute;
  width: 4px; height: 4px;
  background: rgba(255,209,0,0.35);
  border-radius: 50%;
  animation: drift linear infinite;
}
@keyframes drift {
  0% { transform: translateY(0) scale(1); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-100vh) scale(0.5); opacity: 0; }
}

/* logo */
.logo-wrap {
  text-align: center;
  position: relative;
  z-index: 2;
  margin-bottom: 8px;
}
.crown-icon {
  font-size: 54px;
  filter: drop-shadow(0 4px 10px rgba(255,209,0,0.45));
  animation: crownBounce 2s ease-in-out infinite;
}
@keyframes crownBounce {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.logo-text {
  font-size: 68px;
  font-weight: 800;
  letter-spacing: 6px;
  line-height: 1;
  text-shadow:
    0 4px 0 rgba(0,0,0,0.6),
    0 8px 24px rgba(0,0,0,0.4),
    0 0 35px rgba(255,209,0,0.2);
}
.l { display: inline-block; animation: letterPop .6s ease-out backwards; }
.l:nth-child(1) { animation-delay: .1s; }
.l:nth-child(2) { animation-delay: .2s; }
.l:nth-child(3) { animation-delay: .3s; }
.l:nth-child(4) { animation-delay: .4s; }
@keyframes letterPop {
  0% { transform: translateY(30px) scale(0.3); opacity: 0; }
  60% { transform: translateY(-5px) scale(1.1); }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.l-red { color: var(--red); }
.l-blue { color: var(--blue); }
.l-yellow { color: var(--yellow); }
.l-green { color: var(--green); }
.logo-subtitle {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 12px;
  color: var(--gold);
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  margin-top: -4px;
  padding-left: 12px;
}

/* player select */
.player-select {
  width: 100%;
  position: relative;
  z-index: 2;
}
.section-title {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.player-cards {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.pcard {
  background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  color: var(--text-muted);
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  transition: all .2s;
  min-width: 85px;
}
.pcard .pcard-icon { font-size: 22px; }
.pcard:hover { border-color: rgba(255,209,0,0.4); color: #fff; }
.pcard.selected {
  border-color: var(--gold);
  background: linear-gradient(145deg, rgba(255,209,0,0.2), rgba(255,209,0,0.05));
  color: var(--gold);
  box-shadow: 0 0 20px rgba(255,209,0,0.2), inset 0 0 15px rgba(255,209,0,0.08);
}

/* mode buttons */
.mode-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 2;
}
.mode-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 20px;
  border-radius: 16px;
  border: 2px solid;
  cursor: pointer;
  color: #fff;
  font-family: inherit;
  text-align: left;
  transition: all .15s;
  box-shadow: 0 5px 0 rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.25);
  position: relative;
  overflow: hidden;
}
.mode-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 60%);
  pointer-events: none;
}
.mode-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.35), 0 4px 12px rgba(0,0,0,0.25);
}
.mode-btn.computer {
  background: linear-gradient(145deg, #DE2327, #B71C1C);
  border-color: #FF5252;
}
.mode-btn.passnplay {
  background: linear-gradient(145deg, #009FE3, #006699);
  border-color: #40C4FF;
}
.mode-btn-icon { font-size: 34px; flex-shrink: 0; }
.mode-btn-text { display: flex; flex-direction: column; }
.mode-btn-title { font-size: 18px; font-weight: 800; letter-spacing: 1px; }
.mode-btn-sub { font-size: 12px; opacity: .75; font-weight: 500; }

/* ===== GAME SCREEN ===== */
.game {
  padding: 6px 8px;
  justify-content: space-between;
}

.game-header {
  display: flex;
  justify-content: flex-end;
  padding: 2px 4px;
}

.leave-game {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(222, 35, 39, 0.85);
  backdrop-filter: blur(6px);
  border: 2px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .15s;
}
.leave-game:hover { background: var(--red); transform: scale(1.1); }

/* Player Cards Top & Bottom */
.game-top, .game-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
  flex-shrink: 0;
}
.game-bottom { justify-content: space-between; }

/* Authentic Ludo King Player Card */
.player-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: linear-gradient(160deg, #0f305c 0%, #081d3d 100%);
  border: 2px solid #1a5699;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  min-width: 120px;
  max-width: 150px;
  position: relative;
  transition: all .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Active Turn Border Themes (Player Color Matched) */
.player-card.active-turn {
  background: linear-gradient(160deg, #134685 0%, #0a2752 100%);
}

.player-card.red.active-turn {
  border-color: #FF3B30;
  box-shadow: 0 0 16px rgba(255,59,48,0.5), 0 0 30px rgba(255,59,48,0.2);
}
.player-card.red.active-turn::before { border-color: #FF3B30; }
.player-card.red.active-turn .pc-avatar { border-color: #FF3B30; }

.player-card.green.active-turn {
  border-color: #00E676;
  box-shadow: 0 0 16px rgba(0,230,118,0.5), 0 0 30px rgba(0,230,118,0.2);
}
.player-card.green.active-turn::before { border-color: #00E676; }
.player-card.green.active-turn .pc-avatar { border-color: #00E676; }

.player-card.yellow.active-turn {
  border-color: #FFD600;
  box-shadow: 0 0 16px rgba(255,214,0,0.5), 0 0 30px rgba(255,214,0,0.2);
}
.player-card.yellow.active-turn::before { border-color: #FFD600; }
.player-card.yellow.active-turn .pc-avatar { border-color: #FFD600; }

.player-card.blue.active-turn {
  border-color: #00B0FF;
  box-shadow: 0 0 16px rgba(0,176,255,0.5), 0 0 30px rgba(0,176,255,0.2);
}
.player-card.blue.active-turn::before { border-color: #00B0FF; }
.player-card.blue.active-turn .pc-avatar { border-color: #00B0FF; }

.player-card.active-turn::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 12px;
  border: 2px solid;
  animation: turnPulse 1.5s infinite;
  pointer-events: none;
}
@keyframes turnPulse {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(1.03); }
}

.pc-avatar-wrap {
  position: relative;
  width: 38px; height: 38px;
  flex-shrink: 0;
}
.pc-avatar {
  width: 38px; height: 38px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.4);
  background: #0d2a4f;
  transition: border-color .3s;
}

.pc-pin {
  position: absolute;
  bottom: -4px; right: -4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  border: 1px solid #fff;
}
.pc-pin.red { background: var(--red); }
.pc-pin.green { background: var(--green); }
.pc-pin.yellow { background: var(--yellow); }
.pc-pin.blue { background: var(--blue); }

.pc-mic {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1.5px solid #fff;
  border-radius: 50%;
  background: #18b967;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,.35);
}
.pc-mic svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.pc-mic.muted { background: #d9363e; }
.pc-mic.muted::after { content: ''; position: absolute; width: 13px; height: 2px; background: #fff; transform: rotate(-45deg); border-radius: 2px; }

.pc-info {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  overflow: hidden;
}
.pc-level {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 700;
}
.pc-name {
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pc-coins {
  font-size: 10px;
  color: var(--gold);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 3px;
}
.pc-dots {
  display: flex;
  gap: 3px;
  margin-top: 2px;
}
.pc-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #00FF66;
  opacity: 0.8;
}

/* Board Area */
.board-area {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 0;
  padding: 4px 0;
}

.board-frame {
  position: relative;
  display: grid;
  place-items: center;
  background: #061836;
  padding: 4px;
  border-radius: 3px;
  border: 3px solid #0d315e;
  box-shadow:
    0 10px 40px rgba(0,0,0,0.7),
    0 0 60px rgba(0,159,227,0.15);
}

#board {
  /* Keep the full board visible above the player/dice strip on short screens. */
  width: min(94vw, 440px, calc(100dvh - 215px));
  height: min(94vw, 440px, calc(100dvh - 215px));
  border-radius: 0;
  display: block;
}

.turn-banner {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%) scale(.9);
  background: linear-gradient(145deg, rgba(7, 25, 54, 0.92), rgba(4, 15, 33, 0.85));
  backdrop-filter: blur(10px);
  padding: 8px 20px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 15px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  border: 1px solid rgba(255,209,0,0.3);
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
  z-index: 5;
}
.turn-banner.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }

/* Center Dice Button & Yellow Turn Arrow */
.dice-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.turn-arrow {
  position: absolute;
  top: -30px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(0);
  transition: opacity .2s;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.turn-arrow.show {
  opacity: 1;
  animation: arrowBob .7s ease-in-out infinite alternate;
}
@keyframes arrowBob {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

.dice-btn {
  width: 68px; height: 68px;
  border-radius: 16px;
  background: linear-gradient(145deg, #FFFFFF 0%, #E6EEF8 100%);
  border: 3.5px solid var(--gold);
  cursor: pointer;
  box-shadow:
    0 5px 0 var(--gold-dark),
    0 8px 20px rgba(0,0,0,0.4);
  transition: all .1s;
  display: grid;
  place-items: center;
  padding: 5px;
  position: relative;
}
.dice-btn:disabled { opacity: 0.7; cursor: default; }
.dice-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--gold-dark), 0 3px 10px rgba(0,0,0,0.4);
}
.dice-btn.rolling { animation: diceShake .5s ease-in-out; }
@keyframes diceShake {
  0%,100% { transform: rotate(0deg) scale(1); }
  15% { transform: rotate(-20deg) scale(1.1); }
  30% { transform: rotate(15deg) scale(1.05); }
  45% { transform: rotate(-12deg) scale(1.1); }
  60% { transform: rotate(8deg) scale(1.05); }
  75% { transform: rotate(-5deg) scale(1.08); }
}
.dice-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 1px;
  margin-top: 3px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* ===== IN-MATCH CHAT & VOICE ===== */
.match-comms { position: absolute; left: 10px; top: 8px; z-index: 10; }
.comms-btn {
  width: 42px; height: 42px; padding: 0; display: grid; place-items: center;
  border: 2px solid #ffd100; border-radius: 50%; cursor: pointer; color: #fff;
  background: linear-gradient(145deg, #15579e, #092f61);
  box-shadow: 0 3px 0 #07244d, 0 5px 12px rgba(0,0,0,.38);
}
.comms-btn svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.comms-btn svg circle { fill: currentColor; stroke: none; }
.match-chat {
  position: absolute; z-index: 25; left: 10px; right: 10px; bottom: 10px;
  padding: 10px; border: 2px solid #ffd100; border-radius: 15px;
  background: linear-gradient(150deg, rgba(17, 66, 126, .98), rgba(5, 27, 62, .98));
  box-shadow: 0 10px 25px rgba(0,0,0,.48); transform: translateY(calc(100% + 18px));
  opacity: 0; pointer-events: none; transition: transform .22s ease, opacity .22s ease;
}
.match-chat.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.chat-title { display: flex; align-items: center; justify-content: space-between; color: #fff; font-size: 14px; font-weight: 800; }
.chat-title button { border: 0; background: transparent; color: #b9d7ff; font: inherit; font-size: 24px; line-height: 1; cursor: pointer; }
.chat-messages { min-height: 34px; max-height: 82px; overflow-y: auto; padding: 5px 0; }
.chat-message { width: fit-content; max-width: 90%; padding: 4px 9px; border-radius: 9px; background: rgba(255,255,255,.13); color: #fff; font-size: 12px; font-weight: 600; }
.quick-messages { display: flex; gap: 5px; margin: 3px 0 8px; overflow-x: auto; }
.quick-messages button { flex: 0 0 auto; border: 1px solid rgba(255,255,255,.3); border-radius: 12px; background: rgba(255,255,255,.1); color: #dbeeff; padding: 3px 8px; font: 700 10px "Baloo 2", sans-serif; cursor: pointer; }
.chat-composer { display: flex; gap: 7px; }
.chat-composer input { min-width: 0; flex: 1; border: 1px solid rgba(255,255,255,.35); border-radius: 10px; padding: 7px 9px; outline: none; background: #fff; color: #12345e; font: 600 12px "Baloo 2", sans-serif; }
.chat-composer button { width: 34px; border: 0; border-radius: 10px; background: #ffd100; color: #093364; cursor: pointer; display: grid; place-items: center; }
.chat-composer svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }

/* ===== MODAL & TOAST ===== */
.modal {
  position: absolute; inset: 0;
  display: none;
  place-items: center;
  z-index: 50;
}
.modal.show { display: grid; }
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
}
.modal-card {
  position: relative;
  background: linear-gradient(160deg, #0F3A6E, #081C3A);
  border: 3px solid var(--gold);
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  width: 85%;
  max-width: 320px;
  box-shadow: 0 0 60px rgba(255,209,0,0.2), 0 20px 60px rgba(0,0,0,0.6);
  z-index: 1;
}
/* confetti overlay — pieces fall across the whole screen behind the card */
.confetti-wrap {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  will-change: transform, opacity;
  animation-name: confettiFall;
  animation-timing-function: linear;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

.trophy { font-size: 64px; margin-bottom: 8px; animation: trophyBounce 1s ease-out; }
@keyframes trophyBounce {
  0% { transform: scale(0) rotate(-30deg); }
  50% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.modal-card h2 {
  color: var(--gold);
  font-size: 28px;
  margin: 8px 0;
  text-shadow: 0 2px 8px rgba(255,209,0,0.3);
}
.go-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }
.winner-tokens { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; }

.big-btn {
  width: 100%;
  padding: 14px 20px;
  border-radius: 14px;
  border: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  color: #071936;
  background: linear-gradient(145deg, #FFD100, #FFA000);
  box-shadow: 0 4px 0 #C69200, 0 6px 16px rgba(0,0,0,0.3);
  margin-bottom: 8px;
  transition: all .15s;
}
.big-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #C69200; }
.big-btn.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: none;
}

.toast {
  position: absolute;
  top: 15px; left: 50%;
  transform: translateX(-50%) translateY(-30px);
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid rgba(255,209,0,0.3);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  pointer-events: none;
  opacity: 0;
  transition: all .25s ease-out;
  z-index: 100;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================= AUTH SCREEN ================= */
.screen.auth { justify-content: center; align-items: center; gap: 20px; }
.logo-wrap.small { transform: scale(.8); }
.auth-card {
  width: 100%; max-width: 340px;
  background: linear-gradient(#0c4691, #072a5e);
  border: 3px solid var(--gold, #ffd23f); border-radius: 18px;
  padding: 22px 18px; box-shadow: 0 16px 50px rgba(0,0,0,.5);
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tab {
  flex: 1; background: #0a3d80; border: 2px solid #3d84dd; color: #cfe0ff;
  font-weight: 800; font-size: 16px; padding: 9px; border-radius: 10px; cursor: pointer;
  font-family: inherit;
}
.auth-tab.active { background: var(--gold, #ffd23f); color: #5a3600; border-color: var(--gold, #ffd23f); }
.auth-form { display: none; flex-direction: column; gap: 12px; }
.auth-form.active { display: flex; }
.auth-form input {
  background: #072a5e; border: 2px solid #3d84dd; border-radius: 10px;
  color: #fff; padding: 12px 14px; font-size: 15px; font-family: inherit;
}
.auth-form input::placeholder { color: #7fa8dd; }
.auth-error { color: #ffb3b3; font-size: 13px; min-height: 16px; text-align: center; }
.auth-note { text-align: center; color: #cfe0ff; font-size: 13px; margin-top: 14px; }
.auth-note b { color: var(--gold, #ffd23f); }

/* ================= HOME WALLET BAR ================= */
.wallet-bar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; z-index: 5;
}
.wb-user { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.28); border-radius: 22px; padding: 4px 12px 4px 4px; font-weight: 700; font-size: 14px; }
.wb-avatar { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--gold, #ffd23f); object-fit: cover; }
.wb-right { display: flex; align-items: center; gap: 8px; }
.wb-coins {
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(#0e3d80, #072a5e); border: 1px solid #2f7be0;
  border-radius: 22px; padding: 5px 6px 5px 8px; color: #fff; font-weight: 800; font-size: 15px;
  cursor: pointer; font-family: inherit;
}
.wb-coins img { width: 22px; height: 22px; object-fit: contain; }
.wb-plus { background: var(--green, #22a745); border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; font-size: 13px; }
.wb-logout { background: rgba(0,0,0,.28); border: none; color: #cfe0ff; width: 36px; height: 36px; border-radius: 50%; font-size: 18px; cursor: pointer; }

/* ================= WALLET SCREEN ================= */
.screen.wallet { align-items: center; overflow-y: auto; }
.wallet-inner {
  width: 100%; max-width: 420px; margin: auto; position: relative;
  background: linear-gradient(#0c4691, #072a5e);
  border: 3px solid var(--gold, #ffd23f); border-radius: 18px; padding: 18px 16px 26px;
}
.balance-box {
  display: flex; align-items: center; gap: 14px; justify-content: center;
  background: rgba(0,0,0,.22); border-radius: 14px; padding: 14px; margin-bottom: 16px;
}
.balance-box img { width: 46px; height: 46px; object-fit: contain; }
.balance-label { font-size: 12px; color: #cfe0ff; }
.balance-val { font-size: 30px; font-weight: 800; color: var(--gold, #ffd23f); }

.wallet-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.wtab { flex: 1; background: #0a3d80; border: 2px solid #3d84dd; color: #cfe0ff; font-weight: 800; padding: 9px 4px; border-radius: 10px; cursor: pointer; font-family: inherit; font-size: 14px; }
.wtab.active { background: var(--gold, #ffd23f); color: #5a3600; border-color: var(--gold, #ffd23f); }
.wpane { display: none; flex-direction: column; gap: 10px; }
.wpane.active { display: flex; }
.wpane-help { font-size: 13px; color: #bcd6f7; line-height: 1.5; background: rgba(0,0,0,.18); border-radius: 10px; padding: 10px; }
.wlabel { font-size: 13px; font-weight: 700; color: #cfe0ff; margin-top: 4px; }
.wpane input, .wpane textarea {
  background: #072a5e; border: 2px solid #3d84dd; border-radius: 10px;
  color: #fff; padding: 11px 13px; font-size: 15px; font-family: inherit; resize: vertical;
}
.wpane input::placeholder, .wpane textarea::placeholder { color: #7fa8dd; }
.amount-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.amount-chips button { flex: 1; min-width: 60px; background: #0a3d80; border: 2px solid #3d84dd; color: #fff; font-weight: 800; padding: 9px; border-radius: 10px; cursor: pointer; font-family: inherit; }
.amount-chips button:active { background: var(--gold, #ffd23f); color: #5a3600; }

.pay-methods { display: flex; flex-direction: column; gap: 8px; }
.pm-card { display: flex; align-items: flex-start; gap: 10px; background: rgba(0,0,0,.2); border: 2px solid #3d84dd; border-radius: 12px; padding: 12px; cursor: pointer; }
.pm-card.selected { border-color: var(--gold, #ffd23f); box-shadow: 0 0 0 1px var(--gold, #ffd23f) inset; }
.pm-card input { margin-top: 3px; }
.pm-label { font-weight: 800; margin-bottom: 3px; }
.pm-kind { font-size: 10px; background: #12324f; color: #7cc4ff; border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
.pm-line { font-size: 13px; color: #cfe0ff; }
.empty-note { color: #bcd6f7; font-size: 13px; text-align: center; padding: 14px; }

.history-list { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.tx-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: rgba(0,0,0,.2); border-radius: 10px; padding: 10px 12px; }
.tx-type { font-weight: 700; font-size: 14px; }
.tx-note { font-size: 11px; color: #a9c4e6; }
.tx-amt { font-weight: 800; font-size: 16px; }
.tx-row.pos .tx-amt { color: #6ee7a0; }
.tx-row.neg .tx-amt { color: #ff9b9b; }

.back-btn {
  position: absolute; left: 12px; top: 12px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--gold, #ffd23f); border: none; color: #5a3600; font-size: 20px; cursor: pointer; z-index: 2;
  display: grid; place-items: center;
}

/* ================= RECHARGE SUCCESS POPUP ================= */
.recharge-modal-card { max-width: 340px; }
.rm-check {
  width: 72px; height: 72px; margin: 0 auto 8px;
  display: grid; place-items: center;
  animation: rmPop .4s cubic-bezier(.2,1.4,.5,1);
}
@keyframes rmPop { 0% { transform: scale(0); } 100% { transform: scale(1); } }
.recharge-modal-card h2 { color: var(--gold, #ffd23f); margin: 6px 0 10px; }
.rm-line { display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; font-size: 15px; }
.rm-line b { display: inline-flex; align-items: center; gap: 4px; color: var(--gold, #ffd23f); }
.rm-sub { font-size: 13px; color: #cfe0ff; line-height: 1.5; margin: 10px 0; }
.rm-ref { font-size: 13px; color: #bcd6f7; background: rgba(0,0,0,.22); border-radius: 10px; padding: 8px; margin-bottom: 12px; }
.rm-ref b { color: #fff; letter-spacing: 1px; }

/* ================= HOME OFFER POPUP ================= */
.offer-modal-card { max-width: 340px; overflow: hidden; }
.offer-close {
  position: absolute; top: 8px; right: 12px;
  background: rgba(0,0,0,.25); border: none; color: #fff;
  width: 30px; height: 30px; border-radius: 50%; font-size: 20px; cursor: pointer; z-index: 2;
}
.offer-emoji { font-size: 56px; animation: rmPop .5s cubic-bezier(.2,1.4,.5,1); }
.offer-image { width: calc(100% + 48px); margin: -24px -24px 8px; display: block; max-height: 200px; object-fit: cover; }
.offer-ribbon {
  display: inline-block; background: linear-gradient(#e53935, #b71c1c);
  color: #fff; font-weight: 800; font-size: 12px; letter-spacing: 2px;
  padding: 4px 16px; border-radius: 999px; margin: 8px 0 4px;
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
}
.offer-modal-card h2 { color: var(--gold, #ffd23f); margin: 6px 0; }
.offer-msg { font-size: 15px; color: #eaf2ff; line-height: 1.5; margin: 8px 0 14px; white-space: pre-wrap; }

/* ================= COUPON FIELD ================= */
.coupon-row { display: flex; gap: 8px; }
.coupon-row input { flex: 1; text-transform: uppercase; }
.coupon-row button {
  background: var(--green, #22a745); border: none; color: #fff; font-weight: 800;
  padding: 0 18px; border-radius: 10px; cursor: pointer; font-family: inherit; font-size: 15px;
}
.coupon-msg { font-size: 13px; min-height: 14px; }
.coupon-msg.ok { color: #6ee7a0; }
.coupon-msg.err { color: #ffb3b3; }
.rm-bonus { font-size: 13px; color: #6ee7a0; background: rgba(34,167,69,.15); border: 1px solid rgba(34,167,69,.4); border-radius: 10px; padding: 8px; margin-bottom: 10px; }
.rm-bonus b { color: #8cf3b3; }

/* ================= INLINE SVG ICONS ================= */
.svg-icon { display: inline-block; vertical-align: middle; }
.inline-icon { display: inline-flex; align-items: center; vertical-align: middle; }
.inline-icon .svg-icon { display: block; }
/* keep coins in text baselines tidy */
.pc-coins .svg-icon, .go-sub .svg-icon, .auth-note .svg-icon, .rm-line .svg-icon { vertical-align: -3px; }
.crown-icon .svg-icon { filter: drop-shadow(0 3px 4px rgba(0,0,0,.35)); }
.wb-coins .svg-icon { filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.mode-btn-icon img { width: 40px; height: 40px; object-fit: contain; }
.trophy .svg-icon { filter: drop-shadow(0 6px 10px rgba(0,0,0,.4)); }
.rm-check .svg-icon { filter: drop-shadow(0 4px 10px rgba(34,167,69,.5)); }
.offer-emoji .svg-icon { filter: drop-shadow(0 4px 8px rgba(0,0,0,.3)); }

/* ================= PLAY NOW (home) ================= */
.play-now-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 20px; }
.play-now-btn {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(#2fd158, #159b30);
  border: 3px solid #7be08a; border-radius: 18px;
  color: #fff; font-weight: 800; font-size: 26px; letter-spacing: 1px;
  padding: 18px 46px; cursor: pointer; box-shadow: 0 6px 0 #0d7a24, 0 10px 20px rgba(0,0,0,.4);
  animation: pnPulse 1.8s ease-in-out infinite;
}
.play-now-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #0d7a24; }
@keyframes pnPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.play-now-sub { color: #cfe0ff; font-size: 14px; }

/* ================= LOBBY ================= */
.screen.lobby { align-items: center; overflow-y: auto; padding-top: 60px; }
.lobby-scroll { width: 100%; max-width: 440px; margin: auto; display: flex; flex-direction: column; gap: 8px; padding-bottom: 30px; }
.lobby .player-cards { display: flex; gap: 10px; justify-content: center; margin-bottom: 10px; }
.amount-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.amt-btn {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  background: linear-gradient(#0e3d80, #072a5e); border: 2px solid #3d84dd;
  color: #fff; font-weight: 800; font-size: 14px; padding: 12px 4px; border-radius: 10px; cursor: pointer; font-family: inherit;
}
.amt-btn.selected { background: linear-gradient(#ffe27a, #f0a500); color: #5a3600; border-color: #fff; }
.amt-btn .svg-icon { vertical-align: middle; }
.find-match-btn { background: linear-gradient(#2fd158, #159b30); border-color: #7be08a; box-shadow: 0 4px 0 #0d7a24; }
.lobby-note { text-align: center; color: #bcd6f7; font-size: 12px; margin-top: 8px; line-height: 1.5; }

/* ================= MATCHMAKING ================= */
.screen.matchmaking { align-items: center; justify-content: center; }
.mm-inner { text-align: center; max-width: 360px; padding: 20px; }
.mm-spinner {
  width: 90px; height: 90px; margin: 0 auto 10px; border-radius: 50%;
  border: 7px solid rgba(255,255,255,.15); border-top-color: var(--gold, #ffd23f);
  animation: spin 1s linear infinite; position: relative;
}
@keyframes spin { to { transform: rotate(360deg); } }
.mm-countdown { margin-top: -62px; margin-bottom: 30px; font-size: 30px; font-weight: 800; color: var(--gold, #ffd23f); }
.mm-title { color: #fff; font-size: 24px; margin-bottom: 6px; }
.mm-meta { color: var(--gold, #ffd23f); font-weight: 700; margin-bottom: 12px; display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; }
.mm-meta .svg-icon { vertical-align: middle; }
.mm-status { color: #cfe0ff; font-size: 15px; margin-bottom: 10px; }
.mm-pot { background: rgba(0,0,0,.25); border-radius: 20px; padding: 8px 16px; display: inline-flex; align-items: center; gap: 4px; font-weight: 700; margin-bottom: 20px; }

/* ================= BOT (Computer) opponent label ================= */
.player-card.is-bot .pc-name { color: #cfe0ff; }
.bot-tag {
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(#2c86e8, #1258af); color: #fff;
  font-size: 9px; font-weight: 800; letter-spacing: 1px;
  padding: 1px 7px; border-radius: 999px; border: 1px solid #fff;
}
.pc-avatar-wrap { position: relative; }

/* ================= GAME RESULT POPUP (win / lose) ================= */
.result-card { padding-top: 44px; }
.result-badge {
  width: 96px; height: 96px; margin: 0 auto 6px;
  border-radius: 50%;
  display: grid; place-items: center;
  animation: trophyBounce 0.7s cubic-bezier(.2,1.4,.5,1);
}
.result-card.win .result-badge {
  background: radial-gradient(circle at 40% 30%, #fff2a8, #ffc21c 55%, #e0930a);
  box-shadow: 0 0 0 6px rgba(255,209,0,.18), 0 8px 22px rgba(224,147,10,.5);
}
.result-card.lose .result-badge {
  background: radial-gradient(circle at 40% 30%, #4a6a92, #26456e 60%, #16294a);
  box-shadow: 0 0 0 6px rgba(41,64,94,.35), 0 8px 22px rgba(0,0,0,.45);
}
.result-card .trophy { margin: 0; font-size: 0; } /* icon comes from SVG now */

.result-card.win #goTitle { color: var(--gold, #ffd23f); text-shadow: 0 2px 10px rgba(255,209,0,.4); }
.result-card.lose #goTitle { color: #cfe0ff; text-shadow: none; }

.winner-tokens img { width: 34px; height: auto; }

.prize-chip {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(0,0,0,.28); border-radius: 14px;
  padding: 10px 22px; margin: 6px auto 12px;
}
.result-card.win .prize-chip { border: 1px solid rgba(255,209,0,.4); }
.prize-label { font-size: 12px; color: #a9c4e6; letter-spacing: .5px; }
.prize-amt { display: inline-flex; align-items: center; gap: 6px; font-size: 26px; font-weight: 800; }
.result-card.win .prize-amt { color: #6ee7a0; }
.result-card.lose .prize-amt { color: #cfe0ff; }
.prize-amt .svg-icon { vertical-align: middle; }
.go-sub { color: #a9c4e6; font-size: 13px; margin-bottom: 16px; }
