:root {
  --bg-dark: #090d16;
  --card-bg: #151b2e;
  --card-border: #242f4d;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --accent: #10b981;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --red: #ef4444;
  --green: #22c55e;
  --yellow: #eab308;
  --blue: #3b82f6;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
body {
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}
header {
  width: 100%;
  padding: 0.7rem 1.2rem;
  background: #111728;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.logo {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
}
.logo span {
  color: #818cf8;
}
.nav-btn {
  padding: 0.45rem 0.9rem;
  background: #242f4d;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
#sound-toggle-btn.muted {
  opacity: 0.75;
  background: #1e293b;
  color: var(--text-muted);
}
.nav-btn:hover,
.nav-btn:focus-visible {
  background: var(--primary);
  outline: 2px solid #fff;
}

/* Online Multiplayer UI */
.online-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 480px;
  padding: 0.45rem 0.85rem;
  background: #111b2e;
  border: 1px solid #1e293b;
  border-radius: 6px;
  margin-bottom: 0.6rem;
  font-size: 0.82rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.online-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.22rem 0.6rem;
  border-radius: 9999px;
  letter-spacing: 0.5px;
}
.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse-online 1.8s infinite;
}
@keyframes pulse-online {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}
.modal-close-btn {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}
.modal-close-btn:hover {
  color: #fff;
  background: #1e293b;
}

/* Online Lobby Homescreen */
.net-code-box {
  background: #090e1a;
  border: 1px dashed #3b82f6;
  border-radius: 8px;
  padding: 0.8rem;
  margin-bottom: 1rem;
  text-align: center;
}
.net-code-val {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: 4px;
  color: #60a5fa;
  margin-bottom: 0.5rem;
  user-select: all;
}
.net-slot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.8rem;
  background: #0c1322;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}
.net-slot-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.net-slot-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.net-slot-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.net-slot-select {
  padding: 0.3rem 0.5rem;
  background: #1e293b;
  border: 1px solid #334155;
  color: #fff;
  border-radius: 5px;
  font-size: 0.8rem;
  cursor: pointer;
}
.net-slot-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  white-space: nowrap;
}
.net-slot-tag.ready {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.net-slot-tag.waiting {
  background: rgba(234, 179, 8, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(234, 179, 8, 0.35);
}
.net-slot-tag.bot {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}
.net-btn-start {
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  color: #fff;
  background: linear-gradient(135deg, #10b981, #059669);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  transition: all 0.2s ease;
  width: 100%;
}
.net-btn-start:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  background: #242f4d;
}
.net-btn-start:not(:disabled):hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Color Pills for Lobby */
.net-color-pills-row {
  display: flex;
  gap: 0.45rem;
  justify-content: center;
  flex-wrap: wrap;
}
.net-color-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  border: 2px solid transparent;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}
.net-color-pill:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}
.net-color-pill.active {
  border-color: #ffffff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
  transform: scale(1.06);
}
.net-color-pill:disabled,
.net-color-pill.taken {
  opacity: 0.35 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  filter: grayscale(0.65) !important;
  border-color: #334155 !important;
  background: #0f172a !important;
  transform: none !important;
}
.net-color-pill-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

/* Turn Timer Badge */
.turn-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid #334155;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
}
.turn-timer.warning {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.16);
  animation: turnTimerPulse 0.8s infinite alternate ease-in-out;
}
@keyframes turnTimerPulse {
  from { transform: scale(1); box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
  to { transform: scale(1.05); box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
}

/* Ludo Disabled Roll Button & Dice Box */
#ludo-roll-btn:disabled {
  opacity: 0.38 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  filter: grayscale(0.4) !important;
  box-shadow: none !important;
  transform: none !important;
}
.ludo-dice-box:disabled {
  opacity: 0.55 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  box-shadow: none !important;
  transform: none !important;
}
#ludo-roll-btn:not(:disabled) {
  animation: ludoRollGlow 1.8s infinite ease-in-out;
}
@keyframes ludoRollGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
}

.arcade-layout-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 1.5rem;
  width: 100%;
  max-width: 1400px;
  padding: 1rem 0.6rem;
}
main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 1000px;
}

.view {
  display: none;
  width: 100%;
}
.view.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hub-header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding: 0 0.5rem;
}
.hub-header h1 {
  font-size: 1.9rem;
  margin-bottom: 0.3rem;
}
.hub-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.2rem;
  width: 100%;
  max-width: 1000px;
  padding: 0 0.5rem;
}
.hub-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.hub-card-tag {
  font-size: 0.72rem;
  font-weight: bold;
  text-transform: uppercase;
  background: #242f4d;
  color: #a5b4fc;
  padding: 3px 8px;
  border-radius: 4px;
  width: fit-content;
  margin-bottom: 0.6rem;
}
.hub-card h2 {
  font-size: 1.25rem;
  margin-bottom: 0.3rem;
}
.hub-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.35;
  margin-bottom: 1.2rem;
  flex: 1;
}
.play-btn {
  padding: 0.65rem 1.2rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-size: 0.95rem;
}
.play-btn:hover,
.play-btn:focus-visible {
  background: var(--primary-hover);
  outline: 2px solid #fff;
}

.game-wrapper {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1rem 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 100%;
  max-width: 600px;
}
.game-top-bar {
  display: flex;
  justify-content: space-between;
  width: 100%;
  align-items: center;
  margin-bottom: 0.8rem;
  gap: 0.5rem;
}
.game-title {
  font-size: 1.15rem;
  font-weight: 700;
}
.game-controls {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  margin-top: 0.8rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  font-size: 0.9rem;
}
.btn-action {
  padding: 0.55rem 1.1rem;
  background: var(--accent);
  color: #052e16;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}
.btn-action:hover,
.btn-action:focus-visible {
  filter: brightness(1.15);
  outline: 2px solid #fff;
}
.btn-sec {
  padding: 0.45rem 0.9rem;
  background: #334155;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}
.btn-sec:hover,
.btn-sec:focus-visible {
  background: #475569;
  outline: 2px solid #fff;
}

.setup-card {
  background: #111728;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1.5rem 1.2rem;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.setup-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.setup-group label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}
.setup-options-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.opt-btn {
  flex: 1;
  min-width: 70px;
  padding: 0.5rem 0.4rem;
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.82rem;
  text-align: center;
}
.opt-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.color-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 0.4rem;
}
.color-btn {
  padding: 0.5rem 0.2rem;
  border: 2px solid transparent;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.8rem;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.color-btn.active {
  border-color: #fff;
  transform: scale(1.05);
}

.seat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.seat-box {
  background: #1e293b;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
}
.seat-box select {
  background: #0f172a;
  color: #fff;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 0.75rem;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 29, 0.94);
  backdrop-filter: blur(4px);
  border-radius: 14px;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 1rem;
  text-align: center;
}
.modal-overlay.active {
  display: flex;
}
.modal-overlay h2 {
  font-size: 1.8rem;
  margin-bottom: 0.4rem;
  color: #fbbf24;
}

/* LUDO BOARD */
#ludo-board-grid {
  width: min(92vw, 460px);
  height: min(92vw, 460px);
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  background: #cbd5e1;
  border: 3px solid #1e293b;
  border-radius: 8px;
  position: relative;
  user-select: none;
}
.l-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 0.5px solid #e2e8f0;
}
.l-cell.red-bg {
  background: var(--red);
}
.l-cell.green-bg {
  background: var(--green);
}
.l-cell.yellow-bg {
  background: var(--yellow);
}
.l-cell.blue-bg {
  background: var(--blue);
}
.l-cell.safe::after {
  content: "★";
  position: absolute;
  font-size: clamp(12px, 2.8vw, 16px);
  color: #334155;
  pointer-events: none;
  z-index: 2;
}

.ludo-home-center-tile {
  grid-area: 7 / 7 / 10 / 10;
  position: relative;
  width: 100%;
  height: 100%;
  background: #0f172a;
  z-index: 3;
  overflow: hidden;
}
.home-roof-svg {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  inset: 0;
}

.ludo-p-token {
  width: clamp(14px, 4.2vw, 22px);
  height: clamp(14px, 4.2vw, 22px);
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  position: absolute;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ludo-p-token.t-red {
  background: #dc2626;
}
.ludo-p-token.t-green {
  background: #16a34a;
}
.ludo-p-token.t-yellow {
  background: #ca8a04;
}
.ludo-p-token.t-blue {
  background: #2563eb;
}
.ludo-p-token.token-highlight {
  box-shadow: 0 0 0 3px #ffffff, 0 0 10px 4px #fbbf24;
  animation: tokenPulse 0.9s infinite alternate;
  z-index: 20;
}
@keyframes tokenPulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.18);
  }
}
.token-stack-badge {
  background: #000;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  border-radius: 50%;
  width: 13px;
  height: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ludo-dice-box {
  width: 48px;
  height: 48px;
  background: var(--red);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  user-select: none;
  border: none;
}
.ludo-dice-box:focus-visible {
  outline: 3px solid #fff;
}

#carromCanvas {
  width: min(92vw, 460px);
  height: min(92vw, 460px);
  border-radius: 8px;
  touch-action: none;
}

#snakeCanvas {
  width: min(92vw, 380px);
  height: min(92vw, 380px);
  border-radius: 8px;
}
.d-pad-container {
  display: grid;
  grid-template-columns: repeat(3, 50px);
  grid-template-rows: repeat(2, 45px);
  gap: 6px;
  margin-top: 0.8rem;
}
.d-btn {
  background: #1e293b;
  border: 1px solid #334155;
  color: #fff;
  font-size: 1.2rem;
  font-weight: bold;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}
.d-btn:active,
.d-btn:focus-visible {
  background: var(--primary);
  outline: 2px solid #fff;
}

.c4-board {
  background: #1e3a8a;
  padding: 8px;
  border-radius: 12px;
  display: grid;
  grid-template-columns: repeat(7, clamp(34px, 11vw, 48px));
  grid-template-rows: repeat(6, clamp(34px, 11vw, 48px));
  gap: 6px;
  border: 3px solid #172554;
  cursor: pointer;
}
.c4-hole {
  width: 100%;
  height: 100%;
  background: #090d16;
  border-radius: 50%;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
  border: none;
  cursor: pointer;
}
.c4-hole:focus-visible {
  outline: 2px solid #fff;
}
.c4-hole.red {
  background: #ef4444;
}
.c4-hole.yellow {
  background: #eab308;
}

#pongCanvas {
  width: min(92vw, 550px);
  height: auto;
  aspect-ratio: 3 / 2;
  border-radius: 8px;
  touch-action: none;
}

.ad-vertical-side {
  width: 160px;
  min-width: 160px;
  min-height: 600px;
  background: rgba(17, 23, 40, 0.45);
  border: 1px dashed var(--card-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ad-bottom-horizontal {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  margin: 1.2rem auto;
  background: rgba(17, 23, 40, 0.45);
  border: 1px dashed var(--card-border);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

@media (max-width: 1024px) {
  .ad-vertical-side {
    display: none !important;
  }
}

.legal-footer {
  display: flex;
  gap: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.8rem 0;
}
.legal-footer a {
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}
.legal-footer a:hover {
  color: #fff;
}
.legal-footer .link-btn {
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  font-size: inherit;
  padding: 0;
}
.legal-footer .link-btn:hover,
.legal-footer .link-btn:focus-visible,
.legal-footer a:focus-visible {
  color: #fff;
}

ins.adsbygoogle[data-ad-status="unfilled"] {
  display: none !important;
}
.ad-bottom-horizontal:has(ins[data-ad-status="unfilled"]),
.ad-vertical-side:has(ins[data-ad-status="unfilled"]) {
  display: none;
}

.c4-cols {
  display: grid;
  grid-template-columns: repeat(7, clamp(34px, 11vw, 48px));
  gap: 6px;
  padding: 0 11px;
  margin-bottom: 6px;
}
.c4-col-btn {
  height: 28px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}
.c4-col-btn:hover,
.c4-col-btn:focus-visible {
  background: var(--primary);
  outline: 2px solid #fff;
}
.c4-col-btn[aria-disabled="true"] {
  opacity: 0.35;
  cursor: not-allowed;
}

.howto {
  width: 100%;
  max-width: 1000px;
  margin-top: 1.8rem;
  padding: 0 0.5rem;
}
.howto h2 {
  font-size: 1.2rem;
  margin-bottom: 0.6rem;
}
.howto details {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  margin-bottom: 0.5rem;
}
.howto summary {
  cursor: pointer;
  font-weight: 700;
}
.howto details p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
  margin-top: 0.5rem;
}

.carrom-kbd {
  gap: 0.6rem;
  margin-top: 0.4rem;
}
.carrom-kbd label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
}
.carrom-kbd input[type="range"] {
  width: 90px;
}
.carrom-kbd button:disabled,
.carrom-kbd input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .ludo-p-token.token-highlight {
    animation: none;
  }
  .ludo-p-token {
    transition: none;
  }
}
