/* bingo.css */

:root,
html[data-hb-theme="classic"] {
  --hb-accent: #20a0e0;
  --hb-accent-hover: #1588bc;
  --hb-accent-deep: #116e99;
  --hb-accent-ink: #08416e;
  --hb-text-accent: #94eaff;
  --hb-page: #242526;
  --hb-panel: #141416;
  --hb-num: #18191a;
  --hb-num-idle: #3a3f48;
  --hb-num-border: #0d0e11;
  --hb-header-fg: #ffffff;
  --hb-logo-badge: #ffffff;
  --hb-shadow: #1a6d96;
  --hb-called-bg: #ffffff;
  --hb-called-fg: #222222;
}

html[data-hb-theme="hall"] {
  --hb-accent: #e0a020;
  --hb-accent-hover: #c48a12;
  --hb-accent-deep: #8a5a10;
  --hb-accent-ink: #5c3a08;
  --hb-text-accent: #ffe7a3;
  --hb-page: #1c1410;
  --hb-panel: #2a1810;
  --hb-num: #241810;
  --hb-num-idle: #6a5340;
  --hb-num-border: #120c08;
  --hb-header-fg: #fff8e8;
  --hb-logo-badge: #fff4d6;
  --hb-shadow: #5a3a12;
  --hb-called-bg: #fff4d6;
  --hb-called-fg: #3a2408;
}

html[data-hb-theme="neon"] {
  --hb-accent: #e020a8;
  --hb-accent-hover: #b01586;
  --hb-accent-deep: #6e1160;
  --hb-accent-ink: #4a0848;
  --hb-text-accent: #c8ff6a;
  --hb-page: #0a0612;
  --hb-panel: #16081c;
  --hb-num: #120814;
  --hb-num-idle: #5a4060;
  --hb-num-border: #080410;
  --hb-header-fg: #f4e8ff;
  --hb-logo-badge: #f8e8ff;
  --hb-shadow: #5a1060;
  --hb-called-bg: #f8e8ff;
  --hb-called-fg: #2a0830;
}

html[data-hb-theme="forest"] {
  --hb-accent: #3db87a;
  --hb-accent-hover: #2a9460;
  --hb-accent-deep: #1a6a48;
  --hb-accent-ink: #0e4030;
  --hb-text-accent: #b8f0d0;
  --hb-page: #101814;
  --hb-panel: #141c18;
  --hb-num: #121814;
  --hb-num-idle: #4a5a50;
  --hb-num-border: #0a100c;
  --hb-header-fg: #e8fff4;
  --hb-logo-badge: #e8fff0;
  --hb-shadow: #145838;
  --hb-called-bg: #e8fff0;
  --hb-called-fg: #102418;
}

/* --- Core Page Layout --- */
html, body {
  overflow-x: hidden;
  background: var(--hb-page);
  font-family: 'Segoe UI', Arial, sans-serif;
  color: #fff;
  margin: 0;
  height: 100%;
}

/* --- Viewport scaling wrappers --- */
#board-scale-viewport {
  position: static;
  width: 100%;
  height: auto;
  overflow: visible;
}
#board-scale-inner {
  position: static;
  transform: none;
}

/* Content-only scaling wrappers */
#content-scale-viewport {
  position: relative;
  width: 100%;
  height: auto;
  overflow: hidden;
}
#content-scale-inner {
  transform-origin: top left;
}

/* --- Top Bar/Header --- */
.topbar {
  background: var(--hb-accent);
  padding: 16px 0 6px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  position: relative;
  z-index: 1000;
}
.topbar .logo {
  margin-left: 28px;
  font-size: 2.1em;
  font-family: 'Segoe Script', cursive;
  font-weight: 700;
  letter-spacing: 1.5px;
  display: flex;
  align-items: center;
  flex-direction: column;
}
.topbar .logo .fa-b {
  margin-left: 10px;
  font-size: 1.2em;
  background: var(--hb-logo-badge);
  color: var(--hb-accent);
  border-radius: 50%;
  padding: 0.1em 0.32em;
}
.topbar .logo-subline {
  font-size: 0.55em;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--hb-header-fg);
  text-shadow: 0 1px 2px var(--hb-shadow);
  line-height: 1.2;
}
.topbar .icons {
  margin-right: 18px;
  font-size: 1.3em;
}
.countdown-topbar {
  flex: 1;
  text-align: center;
  font-size: 2.1em;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-weight: 700;
  color: var(--hb-header-fg);
  letter-spacing: 1.5px;
  align-self: center;
  margin-left: 24px;
  margin-right: 24px;
  text-shadow: 0 2px 4px var(--hb-shadow);
  min-width: 320px;
  transition: color 0.2s;
}

/* --- Main Layout --- */
.main {
  display: flex;
  justify-content: flex-start;
  width: 100%;
  max-width: none;
  margin: 0 0 30px 20px; /* shift left ~25px */
  padding: 18px 0 0 0;
  box-sizing: border-box;
}
.sidebar {
  /*width: 180px;*/
  padding: 10px 0 0 0;
  flex-shrink: 0;
  text-align: center;
}
.calls-box {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 18px;
  gap: 18px;
}
.calls {
  background: var(--hb-panel);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 4px;
  min-width: 58px;
}
.calls-label {
  color: var(--hb-accent);
  font-size: 0.9em;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}
.calls-value {
  font-size: 2em;
  font-weight: 700;
}
.bingo-card {
  background: var(--hb-panel);
  border-radius: 10px;
  padding: 8px 10px 18px 10px;
  margin-bottom: 16px;
}
.bingo-card table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 auto;
}
.bingo-card th, .bingo-card td {
  border: 1px solid #222;
  width: 30px;
  height: 30px;
  font-size: 1em;
  text-align: center;
  color: #fff;
}
.bingo-card th {
  color: var(--hb-accent);
  font-size: 1em;
  font-weight: 600;
  border-bottom: 2px solid var(--hb-accent);
}
.bingo-card .free {
  background: #555;
  color: #fff;
  font-size: 0.9em;
  font-style: italic;
}
.sidebar .btn {
  background: var(--hb-accent);
  border: none;
  color: #fff;
  padding: 10px 18px;
  font-size: 1.1em;
  border-radius: 6px;
  margin: 8px 0 6px 0;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 600;
}
.sidebar .btn:hover {
  background: var(--hb-accent-hover);
}

/* Global busy/disabled button visuals */
.btn.is-busy {
  position: relative;
  color: #fff !important;
  background: linear-gradient(110deg, rgba(32,160,224,1) 8%, rgba(32,160,224,0.75) 18%, rgba(32,160,224,1) 33%);
  background-size: 200% 100%;
  animation: hbButtonShimmer 1.2s linear infinite;
}
.btn.is-disabled,
.btn[aria-disabled="true"] {
  background: #555 !important;
  color: #bbb !important;
  cursor: not-allowed !important;
  opacity: .95;
}
.btn.is-disabled:hover,
.btn[aria-disabled="true"]:hover {
  background: #555 !important;
}
@keyframes hbButtonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.sidebar .reset {
  background: #111;
  border: 1px solid var(--hb-accent);
  color: var(--hb-accent);
  margin-top: 8px;
  font-size: 1em;
  padding: 7px 12px;
}
.sidebar .reset:hover {
  background: #232b32;
  color: #fff;
}
.sidebar .shortcut-info {
  margin: 10px 0 0 0;
  font-size: 0.93em;
  color: #bbb;
  line-height: 1.5;
}
.content {
  flex: 1;
  padding: 0 0 0 18px;
  min-width: 0;
}
.board-header {
  display: flex;
  align-items: stretch;
  margin-bottom: 6px;
}
.bingocol {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 48px;
  margin-right: 10px;
}
.bingocol .letter {
  font-size: 2.0em;
  color: var(--hb-accent);
  letter-spacing: 2px;
  font-weight: 700;
  margin-bottom: 10px;
}
.board-numbers {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.number-row {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}
.num {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--hb-num);
  border: 2px solid var(--hb-num-border);
  padding: 10px;
  color: var(--hb-num-idle);
  font-size: 2.8em;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
  position: relative;
  opacity: 0.6;
}
/* Subtle, low-contrast look for uncalled numbers */
.num.uncalled {
  border-color: var(--hb-num-border);
  color: var(--hb-num-idle);
  opacity: 0.6;
}
.num.called {
  background: var(--hb-called-bg);
  color: var(--hb-called-fg);
  font-weight: 700;
  border: 2px solid var(--hb-accent);
  opacity: 1;
}
.num.last {
  background: var(--hb-accent);
  color: #fff;
  font-weight: 700;
  border: 2px solid #fff;
  opacity: 1;
  opacity: 1;
  animation: hbCellPop 0.48s cubic-bezier(.2,1.3,.3,1) 0s 1 both,
             hbCellGlow 0.6s ease-out 0s 1 both,
             hbCellWobble 1.2s ease-in-out 0.5s 1 both;
}
@keyframes hbCellPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@keyframes hbCellGlow {
  0% { box-shadow: 0 0 0px var(--hb-accent); }
  100% { box-shadow: 0 0 12px var(--hb-accent); }
}
@keyframes hbCellWobble {
  0% { transform: rotate(0deg) scale(1); }
  20% { transform: rotate(4deg) scale(1.02); }
  40% { transform: rotate(-4deg) scale(1.02); }
  60% { transform: rotate(3deg) scale(1.01); }
  80% { transform: rotate(-3deg) scale(1.01); }
  100% { transform: rotate(0deg) scale(1); }
}

/* --- Footer, Previous Balls --- */
.footer-calls {
  margin: 10px 0 0 15px;
  display: flex;
  align-items: center;
  gap: 46px;
}
.footer-ball {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.footer-prevballs {
  display: flex;
  align-items: center;
  gap: 22px;
}

/* --- Current Ball "Hero" --- */
.ball-current {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, var(--hb-accent) 60%, var(--hb-accent-deep) 100%);
  color: #fff;
  border: 10px solid #fff;
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 3.4em;
  font-weight: 900;
  box-shadow: 0 2px 14px rgba(0,0,0,0.22);
}
.ball-current.is-calling {
  animation: hbBallPop 0.46s cubic-bezier(.2,1.3,.3,1) 0s 1 both,
             hbBallWobble 1.1s ease-in-out 0.18s 1 both;
}
@keyframes hbBallPop {
  0% { transform: scale(1); box-shadow: 0 2px 14px rgba(0,0,0,0.22); }
  35% { transform: scale(1.06); box-shadow: 0 6px 24px rgba(0,0,0,0.32); }
  100% { transform: scale(1); box-shadow: 0 2px 14px rgba(0,0,0,0.22); }
}
@keyframes hbBallWobble {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(3deg) scale(1.03); }
  50% { transform: rotate(-3deg) scale(1.03); }
  75% { transform: rotate(2deg) scale(1.01); }
  100% { transform: rotate(0deg) scale(1); }
}

/* Marching border for just-called cell */
.num.marching::before,
.num.marching::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 14px;
  pointer-events: none;
  z-index: 2;
  will-change: transform;
  /* Show only ring area */
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.num.marching::before {
  padding: 4px; /* base ring thickness */
  background: #ffffff; /* solid base ring for contrast */
  opacity: 1;
}
.num.marching::after {
  inset: -8px; /* slightly larger outer animated ring */
  border-radius: 16px;
  padding: 5px; /* animated ring thickness */
  --hb-ring: #ffd24a; /* marching color */
  background: repeating-conic-gradient(var(--hb-ring) 0deg 18deg, transparent 18deg 30deg);
  animation: hbMarch 1.2s linear infinite;
  filter: drop-shadow(0 0 8px rgba(255,210,74,0.85));
}
@keyframes hbMarch { to { transform: rotate(360deg); } }

/* Flash and blackout effects for reset animation */
.num.flash {
  background: #ffffff !important;
  color: #111 !important;
  border-color: var(--hb-accent) !important;
  box-shadow: 0 0 12px var(--hb-accent);
}
.num.blackout {
  background: #000 !important;
  color: #000 !important;
  border-color: #000 !important;
}
.ball-current .ball-letter {
  font-size: 1.2em;
  margin-bottom: -10px;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: #fff;
  font-weight: 900;
  line-height: 1.1;
}
.ball-current .ball-number {
  font-size: 1.1em;
  color: #fff;
  font-weight: 900;
  line-height: 1.1;
}

/* --- Previous Balls (3D) --- */
.prev-ball.bingo-ball {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  margin-right: 12px;
  background: none;
  border: none;
  box-shadow: none;
  font-size: 1em;
}
.prev-ball .ball-outer {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.prev-ball.B .ball-outer { background: radial-gradient(circle at 65% 30%, #377fff 70%, #0b2ea4 100%); }
.prev-ball.I .ball-outer { background: radial-gradient(circle at 65% 30%, #ff4444 70%, #a40000 100%); }
.prev-ball.N .ball-outer { background: radial-gradient(circle at 65% 30%, #fff 85%, #bbb 100%); }
.prev-ball.G .ball-outer { background: radial-gradient(circle at 65% 30%, #38db50 70%, #156f18 100%); }
.prev-ball.O .ball-outer { background: radial-gradient(circle at 65% 30%, #ffe866 70%, #ccaa00 100%); }
.ball-border {
  width: 86%;
  height: 86%;
  border-radius: 50%;
  background: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 8px solid #fff;
  box-sizing: border-box;
}
.ball-inner {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 6px solid;
  box-sizing: border-box;
}
.prev-ball.B .ball-inner { border-color: #377fff; }
.prev-ball.I .ball-inner { border-color: #ff4444; }
.prev-ball.N .ball-inner { border-color: #ff4444; }
.prev-ball.G .ball-inner { border-color: #38db50; }
.prev-ball.O .ball-inner { border-color: #e1c33f; }
.prev-letter {
  font-size: 2.1em;
  font-weight: 900;
  margin-bottom: -0.18em;
  color: #222;
  line-height: 1;
  letter-spacing: 0.02em;
  font-family: 'Segoe UI', Arial, sans-serif;
}
.prev-ball.N .prev-letter { color: #ff4444; }
.prev-ball.B .prev-letter,
.prev-ball.I .prev-letter,
.prev-ball.G .prev-letter,
.prev-ball.O .prev-letter { color: #222; }
.prev-number {
  font-size: 3.0em;
  font-weight: 900;
  color: #222;
  line-height: 1;
  font-family: 'Segoe UI', Arial, sans-serif;
  margin-bottom: -0.04em;
}

/* --- History Link --- */
.footer-calls .history-link {
  color: #20a0e0;
  font-size: 1em;
  cursor: pointer;
  margin-left: 10px;
  text-decoration: underline;
}

/* --- Reset Dialog --- */
#reset-overlay {
  position: fixed;
  z-index: 9999;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 20, 0.7);
}

/* --- Universal Modal (Alert/Confirm) --- */
.hb-modal {
  position: fixed;
  inset: 0;
  background: rgba(18, 24, 34, 0.88);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeInModal 0.16s;
}

/* === Embedded Pattern Editor Styles (match editor.php) === */
/* Editor content container (when used standalone); not applied in modal now */
.pe-root { background: #c62828; border: 2px solid #fff; border-radius: 12px; box-shadow: 0 4px 24px #0006; padding: 32px 28px 24px 28px; }
.pe-root .pe-title {
  color: #20a0e0;
  font-size: 2em;
  font-weight: 700;
  text-align: center;
  margin-bottom: 10px;
  letter-spacing: 1px;
  text-shadow: 0 2px 8px #1a6d96;
}
.pe-root .pe-help {
  margin: 18px 0 12px 0;
  font-size: 0.9em;
  color: #bbb;
  line-height: 1.4;
  text-align: center;
  user-select: none;
}
.pe-root .pe-name {
  width: 100%;
  max-width: 480px;
  padding: 10px;
  border-radius: 8px;
  border: 1.5px solid #20a0e0;
  background: #232b32;
  color: #fff;
  font-size: 1em;
}
.pe-root .pe-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.pe-root .toggle-switch { position: relative; display: inline-block; width: 38px; height: 22px; vertical-align: middle; }
.pe-root .toggle-switch input { display: none; }
.pe-root .slider { position: absolute; cursor: pointer; top:0;left:0;right:0;bottom:0; background:#4b5563; border-radius:22px; transition: background 0.2s; }
.pe-root .slider:before { position: absolute; content:""; height:18px; width:18px; left:2px; bottom:2px; background:#fff; border-radius:50%; transition: transform 0.2s; }
.pe-root .toggle-switch input:checked + .slider { background:#20a0e0; }
.pe-root .toggle-switch input:checked + .slider:before { transform: translateX(16px); }
.pe-root .frame-btn { background:#232b32; color:#20a0e0; border:1.2px solid #20a0e0; border-radius:6px; padding:5px 12px; font-size:0.97em; font-weight:600; cursor:pointer; }
.pe-root .frame-label { font-size:1em; color:#94eaff; margin:0 3px 0 0; font-weight:600; }

/* Editor action buttons */
.pe-root .btn {
  background: #20a0e0;
  border: none;
  color: #fff;
  padding: 9px 20px;
  font-size: 1em;
  border-radius: 6px;
  margin: 0 7px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}
.pe-root .btn:hover { background: #1588bc; }
.pe-root .btn.pe-clear { background: #444; }
.pe-root .btn.pe-clear:hover { background: #666; }

.pe-root .bingo-table { border-collapse: collapse; margin: 0 auto; background:#08416e; border-radius:10px; overflow:hidden; box-shadow:0 1px 8px #222a; }
.pe-root .bingo-table th, .pe-root .bingo-table td { width:48px; height:48px; text-align:center; vertical-align:middle; border:2px solid #065080; font-size:1.4em; font-weight:600; cursor:pointer; position:relative; background:#fff; color:#222; user-select:none; transition: background 0.2s, box-shadow 0.2s; }
.pe-root .bingo-table th { background:#08416e; color:#fff; font-size:1.2em; font-weight:700; border-bottom:2px solid #20a0e0; cursor:default; }
.pe-root .dot { width:32px; height:32px; background:#20a0e0; border-radius:50%; margin:auto; box-shadow:0 1px 4px #1118; }
.pe-label { font-size: 0.95em; color: #20a0e0; font-weight: 700; }
.pe-root .btn-row { display:flex; gap:8px; justify-content:flex-end; margin-top:8px; }
.hb-modal.show { display: flex; }
.hb-modal .hb-dialog {
  background: #232b32;
  color: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px #000c;
  border: 2px solid #fff;
  min-width: 320px;
  max-width: 92vw;
  padding: 18px 18px 14px 18px;
}
.hb-modal .hb-title {
  font-size: 1.6em;
  font-weight: 800;
  color: #20a0e0;
  margin: 6px 6px 10px 6px;
  text-shadow: 0 2px 8px #1a6d96;
}
.hb-modal .hb-body {
  padding: 6px 6px 12px 6px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.hb-modal .hb-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 6px;
}
.hb-modal .hb-btn {
  background: #20a0e0;
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 1.02em;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s;
}
.hb-modal .hb-btn:hover { background: #1588bc; }
.hb-modal .hb-btn.cancel { background: #444; }
.hb-modal .hb-btn.cancel:hover { background: #2e2e2e; }
.hb-modal .hb-btn.danger { background: #c0392b; }
.hb-modal .hb-btn.danger:hover { background: #a82718; }

/* Top-most modal for nested flows (e.g., Pattern Editor over Setup modal) */
.hb-modal.hb-top { z-index: 4000; }

/* Layout refinements for modals to avoid overflow and large spacing */
.hb-modal .hb-dialog { max-height: 92vh; display:flex; flex-direction:column; }
.hb-modal .hb-dialog { max-width: 980px; width: 96vw; }
.hb-modal .hb-title { margin: 8px 6px 6px 6px; }
.hb-modal .hb-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 6px;
}
.hb-modal .hb-actions { padding: 8px 6px 10px 6px; }

/* Tighter embedded editor spacing inside modals */
.hb-modal .pe-root { padding: 8px 12px 10px 12px; max-width: 450px; margin: 0 auto; }
.hb-modal .pe-title { margin: 4px 0 4px 0; }
.hb-modal .pe-help { margin: 4px 0; line-height: 1.35; }
.hb-modal .pe-row { margin: 2px 0; }
.hb-modal #pe-framebar.pe-row { margin: 2px 0; }
/* Collapse inner element margins inside rows */
.hb-modal .pe-root .pe-row > * { margin: 0; }
.hb-modal .pe-root input.pe-name { margin: 0; }
.hb-modal .pe-root .bingo-table { margin-top: 6px !important; }

/* Specific adjustments for the editor modal */
#hb-editor-modal .hb-dialog { max-width: 540px; width: 96vw; padding: 0; border-radius: 12px; background:#0f1a2b; display: block; }
#hb-editor-modal .hb-title { margin: 0; padding: 0; }
#hb-editor-modal .hb-body { padding: 22px 24px !important; max-height: none; overflow: visible; flex: 0 0 auto !important; display: block; }
#hb-editor-modal .hb-actions { padding: 0; }
#hb-editor-modal .pe-root { padding: 0; max-width: 450px; margin: 0 auto; }

/* Nuclear zero-spacing reset inside the editor modal */
#hb-editor-modal .hb-dialog, #hb-editor-modal .hb-dialog * { margin: 0 !important; padding: 0 !important; gap: 0 !important; }

/* Support case where the editor is mounted inside the universal modal */
#hb-unimodal .hb-dialog { display: block !important; }
#hb-unimodal .hb-body { padding: 0 !important; flex: 0 0 auto !important; display: block !important; overflow: visible !important; }
#hb-unimodal #hb-editor-mount, #hb-unimodal #hb-editor-mount * { margin: 0 !important; padding: 0 !important; gap: 0 !important; }

/* Dashboard styling for embedded pattern editor */
#hb-editor-modal .hb-title { padding: 20px 22px !important; font-weight: 800; color: #eaf3ff; letter-spacing: .02em; }
#hb-editor-modal .hb-dialog { position: relative; }
#hb-editor-modal .hb-close-x { position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; border-radius: 8px; background: #1b2a44; color: #eaf3ff; border: 1px solid #35527e; font-size: 22px; line-height: 30px; text-align: center; cursor: pointer; }
#hb-editor-modal .hb-close-x:hover { background: #223456; }
#hb-editor-modal .pe-ui {
  --card-bg: #0a1322;
  --panel-bg: #0f1a2b;
  --accent: #20a0e0;
  --muted: #9fc3d8;
  --text: #e9f5ff;
  --danger: #d83a3a;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  grid-row-gap: 6px;
  padding: 18px 20px !important;
  background: linear-gradient(180deg, var(--panel-bg), #0a1322);
  color: var(--text);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), 0 6px 22px #0008;
}
#hb-editor-modal .pe-help { font-size: 0.95em; color: var(--muted); }
#hb-editor-modal .hb-title { border-bottom: 1px solid rgba(255,255,255,.08); text-shadow: 0 1px 0 rgba(0,0,0,.35); }
#hb-editor-modal .pe-help { padding-left: 18px !important; }
#hb-editor-modal .pe-name-row { display:grid; grid-template-columns: 120px 1fr auto; align-items:center; column-gap:8px; padding-left: 18px !important; }
#hb-editor-modal .pe-label { color: var(--muted); font-weight:700; }
#hb-editor-modal .pe-name { background:#101826; border:1px solid #2b3e5e; color: var(--text); border-radius:8px; height:34px; padding:0 12px; padding-left:24px !important; }
#hb-editor-modal input.pe-name { padding-left: 10px !important; }
#hb-editor-modal .pe-name::placeholder { color:#7ea2bb; }
#hb-editor-modal .pe-name:focus { outline: 0; border-color: #2aa8e4; box-shadow: 0 0 0 3px rgba(42,168,228,.25); }
#hb-editor-modal #pe-name-warn { color: var(--danger); font-size: .9em; }
#hb-editor-modal .pe-toggle-row { display:flex; align-items:center; gap: 18px; padding-left: 18px !important; margin-top: 10px !important; margin-bottom: 10px !important; }
#hb-editor-modal .pe-row.pe-toggle-row { margin-top: 10px !important; margin-bottom: 10px !important; }
#hb-editor-modal .pe-toggle { display:flex; align-items:center; gap:8px; }
#hb-editor-modal .pe-txt { color: var(--muted); }
#hb-editor-modal .pe-sub { color:#bfb6d8; font-size:.9em; }
#hb-editor-modal .pe-framebar { display:flex; align-items:center; gap:12px !important; justify-content:center; padding-top: 6px; margin-bottom: 10px !important; }
#hb-editor-modal .frame-btn { background:#1d2430; color:var(--accent); border:1px solid var(--accent); border-radius:10px; padding:10px 14px !important; font-weight:800; font-size:1rem; min-height:42px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
#hb-editor-modal .frame-btn.pe-prev, #hb-editor-modal .frame-btn.pe-next, #hb-editor-modal .frame-btn.pe-add, #hb-editor-modal .frame-btn.pe-del { width:42px; height:42px; padding:0 !important; display:inline-flex; align-items:center; justify-content:center; font-size:20px; }
#hb-editor-modal .frame-btn.pe-prev { margin-right: 10px !important; }
#hb-editor-modal .frame-btn.pe-next { margin: 0 10px !important; }
#hb-editor-modal .frame-btn.pe-del { margin-left: 10px !important; }
#hb-editor-modal .frame-label { color: var(--muted); font-weight:800; margin: 0 12px !important; font-size: 1.02rem; }
#hb-editor-modal .pe-board { display:flex; justify-content:center; margin-top: 10px !important; }
#hb-editor-modal .bingo-table { box-shadow: 0 6px 18px rgba(0,0,0,.28); }
#hb-editor-modal .bingo-table tbody td { display: table-cell; vertical-align: middle; position: relative; }
#hb-editor-modal .bingo-table td:hover { background:#f2f8ff; box-shadow: inset 0 0 0 2px rgba(32,160,224,.25); }
#hb-editor-modal .bingo-table td > .dot { position:absolute; top:50%; left:50%; transform: translate(-50%, -50%); margin: 0; background: radial-gradient(ellipse at 30% 30%, #5fd0ff, #1b9ed1 70%); box-shadow: 0 2px 8px rgba(32,160,224,.6), inset 0 1px 2px rgba(255,255,255,.5); }
#hb-editor-modal .btn-row { display:flex; justify-content:flex-end; gap:0; padding: 10px 18px 2px 18px; margin-bottom:5px}
#hb-editor-modal .btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; height:38px; padding:0 44px; border-radius:0; font-weight:800; letter-spacing:.02em; cursor:pointer; box-shadow: 0 6px 16px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.06); transition: transform .04s ease, box-shadow .14s ease, background .14s ease, color .14s ease; }
#hb-editor-modal .btn-row .btn + .btn { border-left: 0; }
#hb-editor-modal .btn-row .btn:first-child { border-top-left-radius:10px; border-bottom-left-radius:10px; }
#hb-editor-modal .btn-row .btn:last-child { border-top-right-radius:10px; border-bottom-right-radius:10px; }
#hb-editor-modal .btn:active { transform: translateY(1px); box-shadow: 0 2px 8px rgba(0,0,0,.3), inset 0 0 0 1px rgba(255,255,255,.06); }
#hb-editor-modal .btn.pe-save { background: linear-gradient(180deg, #27b2f6, #1490cc); color:#07131b; border:1px solid #33a6da; border-left-color:#268fc8; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
#hb-editor-modal .btn.pe-save:hover { background: linear-gradient(180deg, #2ec1ff, #179bd9); }
#hb-editor-modal .btn.pe-clear { background:#2b3342; color:#e8f4ff; border:1px solid #3c4a60; border-right:0; }
#hb-editor-modal .btn.pe-clear, #hb-editor-modal .btn.pe-save { padding-left: 20px !important; padding-right: 20px !important; }
#hb-editor-modal .btn.pe-clear:hover { background:#343e52; }
#hb-editor-modal .btn:focus { outline: 0; box-shadow: 0 0 0 3px rgba(42,168,228,.35), inset 0 0 0 1px rgba(255,255,255,.08); }
#hb-editor-modal .hb-close-x:focus { outline: 0; box-shadow: 0 0 0 3px rgba(42,168,228,.35); }

/* Toggle switch styles within modal scope */
#hb-editor-modal .toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; vertical-align: middle; }
#hb-editor-modal .toggle-switch input { display: none; }
#hb-editor-modal .slider { position: absolute; cursor: pointer; top:0; left:0; right:0; bottom:0; background:#4b5563; border-radius:24px; transition: background 0.2s; box-shadow: inset 0 1px 2px rgba(0,0,0,.35); }
#hb-editor-modal .slider:before { position: absolute; content:""; height:20px; width:20px; left:2px; bottom:2px; background:#fff; border-radius:50%; transition: transform 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
#hb-editor-modal .toggle-switch input:checked + .slider { background:#20a0e0; }
#hb-editor-modal .toggle-switch input:checked + .slider:before { transform: translateX(18px); }

/* Ensure editor table renders correctly inside modal even without .pe-root */
#hb-editor-modal .bingo-table { border-collapse: collapse; margin: 0 auto; background:#08416e; border-radius:10px; overflow:hidden; box-shadow:0 1px 8px #222a; }
#hb-editor-modal .bingo-table { margin: 0 !important; }
#hb-editor-modal .bingo-table th, #hb-editor-modal .bingo-table td { width:48px; height:48px; text-align:center; vertical-align:middle; border:2px solid #065080; font-size:1.4em; font-weight:600; cursor:pointer; position:relative; background:#fff; color:#222; user-select:none; transition: background 0.2s, box-shadow 0.2s; }
#hb-editor-modal .bingo-table th { background:#08416e; color:#fff; font-size:1.2em; font-weight:700; border-bottom:2px solid #20a0e0; cursor:default; }
#hb-editor-modal .dot { width:32px; height:32px; background:#20a0e0; border-radius:50%; margin:auto; box-shadow:0 1px 4px #1118; }

/* Zero spacing for all editor rows and children in the modal */
#hb-editor-modal .pe-help { margin: 0 !important; padding: 0 !important; }
#hb-editor-modal .pe-row { margin: 0 !important; padding: 0 !important; gap: 0 !important; }
#hb-editor-modal .pe-row > * { margin: 0 !important; padding: 0 !important; }
#hb-editor-modal .btn-row { margin: 0 !important; padding: 0 !important; gap: 0 !important; }
#hb-editor-modal .hb-actions { gap: 0 !important; }
#hb-editor-modal input.pe-name { margin: 0 !important; padding: 0 0 0 10px !important; }
#hb-editor-modal .bingo-table th, #hb-editor-modal .bingo-table td { padding: 0 !important; }
#hb-editor-modal .pe-root, #hb-editor-modal .pe-root * { margin: 0 !important; padding: 0 !important; }
/* Editor modal backdrop color */
#hb-editor-modal { background: rgba(0, 0, 0, 0.7); }
#reset-dialog {
  background: #232b32;
  color: #fff;
  padding: 34px 48px 32px 48px;
  border-radius: 16px;
  font-size: 1.22em;
  box-shadow: 0 6px 32px #1118;
  text-align: center;
  font-weight: 500;
}
#reset-dialog .fa-circle-exclamation {
  font-size: 2.6em;
  color: #ffbb44;
  margin-bottom: 10px;
}
#reset-dialog .btn {
  font-size: 1.08em;
  padding: 8px 18px;
  margin: 4px 6px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  min-width: 92px;
  font-weight: 700;
  transition: background 0.2s;
}
#reset-dialog .btn:hover {
  background: #1588bc !important;
  color: #fff;
}

/* --- Responsive Layout Tweaks --- */
@media (max-width: 1200px) {
  .main { padding: 6px 0 0 4px; }
  .content { padding: 0 0 0 8px; }
  .ball-current, .prev-ball.bingo-ball { width: 100px; height: 100px; font-size: 1.5em; }
  .footer-prevballs { gap: 8px; }
  .ball-border { border-width: 5px; }
  .ball-inner { border-width: 4px; }
  .prev-letter { font-size: 1.1em; }
  .prev-number { font-size: 1.8em; }
}
@media (max-width: 900px) {
  .main { flex-direction: column; padding: 2px; }
  .sidebar { width: 100%; display: flex; flex-direction: row; justify-content: space-between; }
  .sidebar > * { flex: 1; }
  .content { padding: 0; }
  .board-header, .number-row { gap: 4px; }
  .bingocol { width: 32px; margin-right: 2px; }
  .num { width: 26px; height: 26px; font-size: 0.98em; }
  .ball-current, .prev-ball.bingo-ball { width: 40px; height: 40px; font-size: 0.8em; }
  .ball-border { border-width: 2px; }
  .ball-inner { border-width: 1.5px; }
  .prev-letter { font-size: 0.6em; }
  .prev-number { font-size: 1em; }
  .bingo-row-label { font-size: 1.2em; }
}

/* --- Bingo Board Layout --- */
#bingo-board {
  display: flex;
  flex-direction: column;
}
.number-row {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}
.bingo-row-label {
  width: 36px;
  min-width: 36px;
  text-align: center;
  font-size: 3em;
  color: #20a0e0;
  font-weight: bold;
  font-family: inherit;
  letter-spacing: 1.5px;
  margin-right: 10px;
  user-select: none;
  padding-left:20px;
}
.number-row .num {
  margin-right: 8px;
}

/* --- Full-width Callboard Mode (no sidebar, no footer) --- */
body.layout-hide-sidebar.layout-hide-footer .board-header { justify-content: center; }
body.layout-hide-sidebar.layout-hide-footer #bingo-board { margin: 10px auto; }
body.layout-hide-sidebar.layout-hide-footer .number-row { gap: 10px; margin-bottom: 8px; }
body.layout-hide-sidebar.layout-hide-footer .bingo-row-label {
  width: 52px;
  min-width: 52px;
  font-size: 2.0em;
}
body.layout-hide-sidebar.layout-hide-footer .num {
  width: 60px;
  height: 60px;
  padding: 12px;
  font-size: 3.4em;
  border-radius: 12px;
}

/* --- Footer Balls Only Mode (no sidebar, no callboard) --- */
body.layout-hide-sidebar.layout-hide-callboard:not(.layout-hide-footer) .footer-calls {
  margin: 10vh auto 0 auto;
  justify-content: center;
  gap: 5vw;
}
body.layout-hide-sidebar.layout-hide-callboard:not(.layout-hide-footer) .ball-current {
  width: 260px;
  height: 260px;
  font-size: 2.2em;
}
body.layout-hide-sidebar.layout-hide-callboard:not(.layout-hide-footer) .prev-ball.bingo-ball {
  width: 260px;
  height: 260px;
  font-size: 2.0em;
}
body.layout-hide-sidebar.layout-hide-callboard:not(.layout-hide-footer) .footer-prevballs { gap: 5vw; }
/* Sharper, larger glyphs inside balls for footer-only view */
body.layout-hide-sidebar.layout-hide-callboard:not(.layout-hide-footer) .prev-letter { 
  font-size: 1.8em; 
  line-height: 1; 
  margin-bottom: -6px; 
}
body.layout-hide-sidebar.layout-hide-callboard:not(.layout-hide-footer) .prev-number { 
  font-size: 2.8em; 
  line-height: .95; 
}
body.layout-hide-sidebar.layout-hide-callboard:not(.layout-hide-footer) .ball-current .ball-letter { 
  font-size: 1.4em; 
  margin-bottom: -12px; 
}
body.layout-hide-sidebar.layout-hide-callboard:not(.layout-hide-footer) .ball-current .ball-number { 
  font-size: 2.4em; 
  line-height: .95; 
}

/* --- Settings Modal --- */
#settings-modal {
  display: none;
  position: fixed;
  z-index: 100;
  left: 0; top: 0; right: 0; bottom: 0;
  background: rgba(30,40,56,0.88);
  justify-content: center;
  align-items: center;
  animation: fadeInModal 0.16s;
}
@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}
.settings-content {
  margin:20px 40px 20px 40px;
}
#settings-dialog {
  background: #232b32;
  color: #fff;
  padding: 34px 36px 30px 36px;
  border-radius: 16px;
  font-size: 1.13em;
  box-shadow: 0 10px 40px #000c;
  text-align: left;
  min-width: 330px;
  max-width: 98vw;
  font-weight: 500;
  position: relative;
  outline: none;
}
#settings-dialog h2 {
  margin-top: 0;
  margin-bottom: 18px;
  color: #20a0e0;
  font-size: 2em;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-align: left;
  text-shadow: 0 2px 8px #1a6d96;
}
#settings-dialog label {
  display: block;
  font-size: 1.12em;
  color: #eee;
  margin-bottom: 6px;
  font-weight: 600;
}
#voice-select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 6px;
  background: #18191a;
  border: 2px solid #20a0e0;
  color: #fff;
  font-size: 1em;
  margin-bottom: 24px;
  margin-top: 2px;
  outline: none;
  font-family: inherit;
  transition: border 0.17s;
}
#voice-select:focus {
  border-color: #44c2ff;
}
.settings-btns {
  text-align: right;
}
.settings-btn {
  background: #20a0e0;
  border: none;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 1.12em;
  margin-right: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  min-width: 110px;
}
.settings-btn:last-child {
  background: #444;
  color: #fff;
  margin-right: 0;
}
.settings-btn:hover:not(:last-child) {
  background: #1588bc;
}
.settings-btn:last-child:hover {
  background: #232b32;
}
@media (max-width: 600px) {
  #settings-dialog {
    min-width: 90vw;
    font-size: 0.99em;
    padding: 12px 6vw 20px 6vw;
  }
  #settings-dialog h2 {
    font-size: 1.4em;
    margin-bottom: 12px;
  }
}

/* --- Pattern Search Styles --- */
.pattern-search-container {
  margin: 20px 0 0 0;
  display: flex;
  justify-content: flex-start;
}
#pattern-search {
  padding: 10px;
  font-size: 1.2em;
  border-radius: 8px;
  width: 350px;
  max-width: 95vw;
  border: 1.5px solid #f0f0f0;
  background: #f0f0f0;
  color: #000;
  outline: none;
  transition: border 0.18s, background 0.15s;
}
#pattern-search:focus {
  border-color: #20a0e0;
  background: #f0f0f0;
}
@media (max-width: 800px) {
  #pattern-search {
    font-size: 1em;
    width: 98vw;
    min-width: 0;
  }
  .pattern-search-container {
    margin-top: 200px;
  }
}
@media (max-width: 500px) {
  #pattern-search {
    font-size: 0.95em;
    width: 96vw;
  }
}

/* --- Blackout Phase Popup --- */
#blackout-phase-popup {
  display: none;
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 0;
  z-index: 400;
  background: rgba(24, 27, 38, 0.92);
  justify-content: center;
  align-items: center;
  pointer-events: none;
}
#blackout-phase-popup .blackout-content {
  margin: 0 auto;
  max-width: 600px;
  background: #111f2b;
  border-radius: 30px;
  padding: 54px 48px;
  box-shadow: 0 8px 40px #000a;
  border: 4px solid #20a0e0;
  text-align: center;
  color: #fff;
  font-size: 2.7em;
  font-weight: 900;
  letter-spacing: 2.5px;
  text-shadow: 0 3px 16px #1a6d96, 0 1px 0 #000, 0 1px 32px #000a;
  animation: blackout-fadein 0.38s cubic-bezier(.6,1.6,.43,1.02);
  pointer-events: all;
}
@keyframes blackout-fadein {
  from { opacity: 0; transform: scale(0.88);}
  to { opacity: 1; transform: scale(1);}
}
#blackout-phase-popup.fade-out {
  animation: blackout-fadeout 0.46s cubic-bezier(.6,1.6,.43,1.02) forwards;
}
@keyframes blackout-fadeout {
  to { opacity: 0; transform: scale(1.09);}
}
.content { position: relative; }
#btn-start-blackout {
  background: #fcd12a;
  color: #18191a;
  border: 2px solid #e4b806;
  font-weight: 800;
  letter-spacing: 1.2px;
  font-size: 1.18em;
  margin-top: 14px;
  box-shadow: 0 2px 12px #fcd12a44;
  transition: background 0.16s, box-shadow 0.18s;
}
#btn-start-blackout:hover {
  background: #ffe066;
  color: #111;
  box-shadow: 0 4px 32px #fcd12a99;
  border-color: #ffe066;
}
@media (max-width: 700px) {
  #blackout-phase-popup .blackout-content {
    padding: 28px 12px;
    font-size: 1.2em;
    border-radius: 16px;
    max-width: 90vw;
  }
}

/* --- Pattern Gallery Thumbnails --- */
.pattern-gallery {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 28px 32px;
  margin: 20px 0 40px 0;
  align-items: start;
}
.pattern-thumb {
  background: #191a1c;
  border-radius: 10px;
  padding: 12px 18px 14px 18px;
  box-shadow: 0 3px 20px rgba(0,0,0,0.10);
  transition: box-shadow 0.15s, transform 0.13s, border-color 0.17s;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 130px;
  min-width: 0;
  cursor: pointer;
  border: 2.5px solid transparent;
  user-select: none;
  outline: none;
  position: relative;
}

/* Grouped actions (Edit/Delete) on pattern thumbs */
.pattern-actions { display:flex; justify-content:center; gap:0; }
.pattern-actions .pattern-edit-btn,
.pattern-actions .pattern-delete-btn {
  display:inline-flex; align-items:center; justify-content:center;
  height:36px; padding:0 16px; font-weight:800; letter-spacing:.02em;
  border:none; cursor:pointer; box-shadow: 0 6px 16px rgba(0,0,0,.28);
}
.pattern-actions .pattern-edit-btn { background:#3a3f46; color:#eaf3ff; border-radius:0; border-top-left-radius:10px; border-bottom-left-radius:10px; }
.pattern-actions .pattern-delete-btn { background:#a8322a; color:#fff; border-radius:0; border-top-right-radius:10px; border-bottom-right-radius:10px; }
/* Ensure inner seam is square */
.pattern-actions .pattern-edit-btn { border-top-right-radius:0; border-bottom-right-radius:0; }
.pattern-actions .pattern-delete-btn { border-top-left-radius:0; border-bottom-left-radius:0; }
.pattern-actions .pattern-edit-btn + .pattern-delete-btn { margin-left:0; }
.pattern-thumb.selected,
.pattern-thumb:focus-visible {
  box-shadow: 0 0 0 4px #20a0e077, 0 7px 32px #20a0e033;
  border-color: #20a0e0;
  z-index: 2;
  transform: scale(1.04);
}
.pattern-thumb:hover {
  box-shadow: 0 0 0 3px #20a0e055, 0 6px 22px #20a0e022;
  border-color: #20a0e0bb;
}
.pattern-thumb.animated::after {
  content: "";
  display: block;
  position: absolute;
  top: 8px;
  right: 10px;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 13px solid #20a0e0;
  opacity: 0.82;
  filter: drop-shadow(0 0 4px #20a0e099);
  animation: playpulse 1.4s infinite cubic-bezier(.5,1.5,.5,1);
}
@keyframes playpulse {
  0%   { filter: drop-shadow(0 0 2px #20a0e088); opacity: 0.8; }
  45%  { filter: drop-shadow(0 0 9px #20a0e0dd); opacity: 1; }
  100% { filter: drop-shadow(0 0 2px #20a0e088); opacity: 0.8; }
}
.pattern-title {
  margin-bottom: 9px;
  font-size: 1.06em;
  font-weight: 600;
  color: #20a0e0;
  text-align: center;
  text-shadow: 0 2px 8px #0002;
  word-break: break-word;
}
.pattern-title, .pattern-grid { outline: none; }
.pattern-title:focus, .pattern-grid:focus { box-shadow: 0 0 0 3px rgba(32,160,224,.35); border-radius: 6px; }
.pattern-grid {
  background: #222325;
  border-radius: 6px;
  padding: 6px;
  box-shadow: 0 1px 6px #111a;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.pattern-row { display: flex; }
.pattern-cell {
  display: inline-block;
  width: 19px;
  height: 19px;
  margin: 2.2px;
  border-radius: 50%;
  background: #36383c;
  box-shadow: 0 1px 3px #0002;
  border: 1px solid #3e424b;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.12s;
  position: relative;
}
.pattern-cell.marked {
  background: #20a0e0;
  border-color: #fff;
  box-shadow: 0 0 0 2px #20a0e0, 0 2px 8px #10c3f980;
  z-index: 1;
}
.pattern-cell.free-space {
  background: #888 !important;
  border: 1px dashed #eee !important;
  opacity: 0.72;
}
.pattern-error,
.pattern-empty {
  width: 100%;
  text-align: center;
  padding: 30px 0 20px 0;
  color: #ff6565;
  font-size: 1.08em;
  font-weight: 600;
}
.pattern-author {
  font-size: 0.85em;
  color: #8fb9ff;
  margin-top: 2px;
}

/* --- Pattern Preview (Sidebar/Top) --- */
#pattern-preview {
  margin: 10px auto 18px auto;
  padding: 12px 0 14px 0;
  max-width: 170px;
  text-align: center;
  background: #1b1f26;
  border: 2px solid #fff;
  border-radius: 12px;
}
#pattern-preview .pattern-preview-title { display:inline-block; text-align:center; }
.pattern-preview-title {
  color: #20a0e0;
  font-size: 1em;
  font-weight: 700;
  margin-bottom: 12px;
  text-shadow: 0 2px 10px #19244422;
  letter-spacing: 0.5px;
  text-align: center;
  width: 100%;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.pattern-preview-grid {
  background: #23272b;
  border-radius: 8px;
  padding: 10px 10px 11px 10px;
  box-shadow: 0 3px 20px #1b283577;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.preview-row { display: flex; }
.preview-cell {
  display: inline-block;
  width: 28px;
  height: 28px;
  margin: 4.5px;
  border-radius: 50%;
  background: #36383c;
  border: 2px solid #3e424b;
  transition: background 0.18s, border-color 0.16s, box-shadow 0.13s;
  box-shadow: 0 2px 6px #0002;
  position: relative;
}
.preview-cell.marked {
  background: #20a0e0;
  border-color: #fff;
  box-shadow: 0 0 0 4px #20a0e0, 0 2px 4px #10c3f990;
}
.preview-cell.free-space {
  background: #bbb !important;
  border: 2px dashed #eee !important;
  opacity: 0.68;
}
/* If the free space is part of the pattern, highlight it distinctly */
.preview-cell.free-space.free-used {
  background: #ffe866 !important;
  border: 2px solid #fff !important;
  opacity: 1 !important;
  box-shadow: 0 0 0 4px #ffe866, 0 2px 6px #0004 !important;
}
.preview-cell.free-space.free-used::after {
  content: '★';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #111;
  font-weight: 900;
  font-size: 1.8em;
  line-height: 1;
}
/* Larger icon in modal */
.pattern-modal-grid .preview-cell.free-space.free-used::after { font-size: 3.2em; }
/* Larger cells for pattern modal */
.pattern-modal-grid {
  background:#0f1216;
  border-radius:12px;
  padding:16px 14px;
  box-shadow:0 8px 40px #000b, inset 0 0 0 2px #1f2630;
  display:flex;
  flex-direction:column;
  align-items:center;
  margin:6px 2px;
}
.pattern-modal-grid .preview-row { display:flex; }
.pattern-modal-grid .preview-row .preview-cell { width: 96px; height: 96px; margin: 12px; }
@media (max-width: 800px) {
  .pattern-gallery { gap: 18px 8px; justify-content: center; }
  .pattern-thumb { width: 96px; padding: 10px 6px 10px 6px; }
  .pattern-grid .pattern-row .pattern-cell { width: 13px; height: 13px; margin: 1.4px; }
  #pattern-preview { max-width: 110px; }
  .pattern-preview-grid .preview-row .preview-cell { width: 18px; height: 18px; margin: 2.1px; }
  #pattern-search { font-size: 1em; width: 98vw; min-width: 0; }
}
@media (max-width: 500px) {
  .pattern-thumb { width: 72px; padding: 5px 2px 7px 2px; }
  .pattern-title { font-size: 0.95em; }
  .pattern-row .pattern-cell { width: 8.5px; height: 8.5px; margin: 1px; }
  #pattern-preview { max-width: 75px; }
  .pattern-preview-grid .preview-row .preview-cell { width: 11px; height: 11px; margin: 1.2px; }
  #pattern-search { font-size: 0.9em; width: 96vw; }
}

/* --- Pattern Thumb Shake Animation --- */
.pattern-thumb.shake { animation: shake .6s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
  100% { transform: translateX(0); }
}

/* --- Menu Dropdown Styles --- */
.menu-dropdown {
  position: absolute;
  top: 58px;
  right: 14px;
  min-width: 190px;
  background: #222b;
  border-radius: 12px;
  box-shadow: 0 8px 28px #0007;
  padding: 12px 0;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  animation: menufadein 0.22s;
  border: 1.5px solid var(--hb-accent);
}
@keyframes menufadein {
  from { opacity: 0; transform: translateY(-14px);}
  to { opacity: 1; transform: translateY(0);}
}
.menu-item {
  padding: 11px 24px;
  color: #fff;
  text-decoration: none;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.14s, color 0.12s;
}
.menu-item[hidden] {
  display: none !important;
}
.menu-item:hover,
.menu-item:focus {
  background: var(--hb-accent);
  color: #18191a;
  outline: none;
}
.pattern-thumb.animated::after { pointer-events: none; }
.pattern-load-btn {
  background: #20a0e0;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1em;
  font-weight: 600;
  padding: 6px 16px;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.15s;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  line-height: 1;
  vertical-align: middle;
}
.pattern-load-btn:hover,
.pattern-load-btn:focus {
  background: #1588bc;
  outline: none;
}
#blackout-dismiss-btn {
  position: absolute;
  top: 10px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 2.8em;
  font-weight: 700;
  color: #ffe866;
  cursor: pointer;
  line-height: 1;
  transition: color 0.3s ease;
  padding: 0;
}
#blackout-dismiss-btn:hover,
#blackout-dismiss-btn:focus {
  color: #fff;
  outline: none;
}
.pattern-edit-btn {
  background: #444;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1em;
  font-weight: 600;
  padding: 6px 16px;
  cursor: pointer;
  transition: background 0.15s;
  margin-left: 8px;
  margin-top:10px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  line-height: 1;
  vertical-align: middle;
}
.pattern-edit-btn:hover,
.pattern-edit-btn:focus {
  background: #666;
  outline: none;
}

/* Delete button for pattern cards */
.pattern-delete-btn {
  background: #8a2727;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1em;
  font-weight: 600;
  padding: 6px 16px;
  cursor: pointer;
  transition: background 0.15s;
  margin-left: 8px;
  margin-top:10px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  line-height: 1;
  vertical-align: middle;
}
.pattern-delete-btn:hover,
.pattern-delete-btn:focus {
  background: #c0392b;
  outline: none;
}
.pattern-create-btn {
  background: #20a0e0;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1em;
  font-weight: 700;
  padding: 18px 24px;
  cursor: pointer;
  box-shadow: 0 3px 20px rgba(32, 160, 224, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 130px;
  user-select: none;
  transition: background 0.3s, box-shadow 0.3s;
}
.pattern-create-btn:hover {
  background: #1588bc;
  box-shadow: 0 4px 32px rgba(21, 136, 188, 0.9);
}
.pattern-create-btn i { font-size: 1.3em; }

/* Setup/Edit dialog primary action button */
#setup-dialog #setup-create.btn {
  background: #20a0e0;
  border: none;
  color: #fff;
  padding: 10px 18px;
  font-size: 1.1em;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 600;
}
#setup-dialog #setup-create.btn:hover {
  background: #1588bc;
}

/* Setup dialog: randomize patterns (same brand cyan as Create Game) */
#setup-dialog .setup-randomize-card {
  align-self: end;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid #2a3a48;
  border-radius: 10px;
  background: #12161b;
}
#setup-dialog .setup-randomize-heading {
  color: #94eaff;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}
#setup-dialog .setup-randomize-btn.btn {
  width: 100%;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #20a0e0;
  border: none;
  color: #fff;
  padding: 10px 16px;
  font-size: 1.02em;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  font-weight: 700;
  box-shadow: 0 2px 12px rgba(32, 160, 224, 0.28);
}
#setup-dialog .setup-randomize-btn.btn:hover {
  background: #1588bc;
  box-shadow: 0 3px 16px rgba(32, 160, 224, 0.4);
}
#setup-dialog .setup-randomize-btn.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(42, 168, 228, 0.4), 0 2px 12px rgba(32, 160, 224, 0.28);
}
#setup-dialog .setup-randomize-btn.btn i {
  font-size: 0.95em;
  opacity: 0.95;
}
#setup-dialog .setup-randomize-hint {
  margin: 0;
  color: #8aa0b4;
  font-size: 11px;
  line-height: 1.45;
}

/* Pattern actions */
#open-pattern-gallery-btn.btn {
  background: #20a0e0;
  border: none;
  color: #fff;
  padding: 10px 18px;
  font-size: 1.05em;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 700;
}
#open-pattern-gallery-btn.btn:hover {
  background: #1588bc;
}

/* Create Pattern button in Pattern Gallery tab */
#btn-create-pattern {
  background: #20a0e0;
  border: none;
  color: #fff;
  padding: 10px 18px;
  font-size: 1.05em;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 700;
}
#btn-create-pattern:hover {
  background: #1588bc;
}

/* Pattern gallery modal create button */
#pattern-gallery-dialog #create-pattern-btn.btn {
  background: #20a0e0;
  border: none;
  color: #fff;
  padding: 10px 18px;
  font-size: 1.05em;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 700;
}
#pattern-gallery-dialog #create-pattern-btn.btn:hover {
  background: #1588bc;
}

/* Left Controls Box */
.sidebar .controls-box {
  background:#1b1f26;
  border:2px solid #fff;
  border-radius:12px;
  padding:10px;
  margin: 8px 0 12px 0;
}
.sidebar .controls-title {
  color:#fff;
  font-weight:700;
  margin-bottom:8px;
  text-align:center;
}
.sidebar .controls-buttons .btn,
.sidebar .controls-buttons .reset {
  display:block;
  width:100%;
  margin:6px 0;
}
/* Browse Patterns under preview */
.sidebar #open-pattern-gallery-btn.btn {
  width:100%;
  border:none;
  box-shadow:none;
}

/* Sidebar stats card (Total Calls / Previous Call / Round) */
.sidebar .stats-card {
  background:#1b1f26;
  border:2px solid #fff;
  border-radius:12px;
  padding:0;
  overflow:hidden;
  margin-bottom:10px;
}
.sidebar .stats-card .row.top {
  display:grid;
  grid-template-columns: 1fr 1fr;
  border-bottom:2px solid #fff;
}
.sidebar .stats-card .row.top .cell {
  padding:10px 12px;
  position:relative;
}
.sidebar .stats-card .row.top .cell:first-child {
  border-right:2px solid #fff;
}
.sidebar .stats-card .row.bottom {
  text-align:center;
  padding:10px 12px 12px 12px;
}
.sidebar .stats-card .label {
  color:#20a0e0;
  font-weight:800;
  font-size:0.95em;
  letter-spacing:.3px;
  text-transform:uppercase;
}
.sidebar .stats-card .row.top .value {
  color:#fff;
  font-size:2.2em;
  font-weight:800;
  line-height:1.2;
}
.sidebar .stats-card .row.bottom .value {
  color:#fff;
  font-size:2em;
  font-weight:800;
}

/* Pattern card that includes preview and browse button */
.sidebar .pattern-card {
  background: var(--hb-panel);
  border:2px solid #fff;
  border-radius:12px;
  padding:10px 10px 12px 10px;
  margin:8px 0 12px 0;
  text-align:center;
  position:relative;
}
.sidebar .pattern-card #open-pattern-gallery-btn.btn {
  width:100%;
  margin-top:10px;
  border:2px solid #fff;
}
/* Remove outer border on inner preview now that it sits in a card */
.sidebar .pattern-card #pattern-preview {
  border:none;
  background:#1b1f26;
  margin: 0 auto 8px auto;
}
/* Enlarge pattern button */
#pattern-enlarge-btn {
  position:absolute;
  right:12px;
  top:12px;
  background:transparent;
  border:2px solid var(--hb-accent);
  color: var(--hb-text-accent);
  border-radius:8px;
  padding:6px 8px;
  cursor:pointer;
  line-height:1;
}
#pattern-enlarge-btn:hover { background:#122230; }

/* Current ball follows the selected callboard theme */
.ball-current {
  border-color: #fff !important;
  background: radial-gradient(ellipse at center, var(--hb-accent) 60%, var(--hb-accent-deep) 100%) !important;
  color: #fff !important;
}
.ball-current .ball-letter, .ball-current .ball-number { color:#fff !important; }

/* Previous balls: white background, colored border by letter; black text */
.prev-ball .ball-inner { background:#fff !important; }
.prev-letter, .prev-number { color:#111 !important; }

/* B = blue */
.prev-ball.B .ball-inner { border-color:#1e88e5 !important; }
.prev-ball.B .prev-letter { color:#111 !important; }
/* I = yellow */
.prev-ball.I .ball-inner { border-color:#f1c40f !important; }
.prev-ball.I .prev-letter { color:#111 !important; }
/* N = purple */
.prev-ball.N .ball-inner { border-color:#8e44ad !important; }
.prev-ball.N .prev-letter { color:#111 !important; }
/* G = green */
.prev-ball.G .ball-inner { border-color:#2ecc71 !important; }
.prev-ball.G .prev-letter { color:#111 !important; }
/* O = red */
.prev-ball.O .ball-inner { border-color:#e74c3c !important; }
.prev-ball.O .prev-letter { color:#111 !important; }

/* Previous balls: ensure white background and colored borders for BOTH outer and inner rings */
.prev-ball .ball-outer { background: none !important; }
.prev-ball .ball-border { border-color: #ccc !important; }
/* B */
.prev-ball.B .ball-border { border-color:#1e88e5 !important; }
.prev-ball.B .ball-inner { border-color:#1e88e5 !important; }
/* I */
.prev-ball.I .ball-border { border-color:#f1c40f !important; }
.prev-ball.I .ball-inner { border-color:#f1c40f !important; }
/* N */
.prev-ball.N .ball-border { border-color:#8e44ad !important; }
.prev-ball.N .ball-inner { border-color:#8e44ad !important; }
/* G */
.prev-ball.G .ball-border { border-color:#2ecc71 !important; }
.prev-ball.G .ball-inner { border-color:#2ecc71 !important; }
/* O */
.prev-ball.O .ball-border { border-color:#e74c3c !important; }
.prev-ball.O .ball-inner { border-color:#e74c3c !important; }

.prev-ball.current .ball-outer { background: var(--hb-accent) !important; }
.prev-ball.current .ball-border { border-color:#fff !important; background: transparent !important; }
.prev-ball.current .ball-inner { background: transparent !important; border-color:#fff !important; }
.prev-ball.current .prev-letter, .prev-ball.current .prev-number { color:#fff !important; }


/* === Themed Scrollbars (Cross-browser) === */
/* Firefox (CSS Scrollbars spec) */
* {
  scrollbar-width: thin;            /* auto | thin | none */
  scrollbar-color: var(--hb-accent) #0f1419; /* thumb | track */
}

/* Chromium / WebKit (Chrome, Edge, Safari, Opera) */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: #0f1419;
  border-radius: 10px;
}
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--hb-text-accent) 0%, var(--hb-accent) 60%, var(--hb-accent-hover) 100%);
  border-radius: 10px;
  border: 2px solid #0f1419; /* creates inset groove */
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #4fccff 0%, #2bb6f0 60%, #1d98d0 100%);
}
*::-webkit-scrollbar-corner {
  background: #0f1419;
}

/* Tweak sizes on small screens */
@media (max-width: 768px) {
  *::-webkit-scrollbar { width: 8px; height: 8px; }
  * { scrollbar-width: thin; }
}

#setup-dialog .setup-tabs {
	/* uses inline border-bottom for divider */
}
#setup-dialog .setup-tab-btn {
	background: transparent;
	color: #cfe8ff;
	border: 1px solid transparent;
	border-bottom: 2px solid transparent;
	border-radius: 8px 8px 0 0;
	padding: 8px 14px;
	cursor: pointer;
	font-weight: 700;
	transition: color .15s, background .15s, border-color .15s, box-shadow .15s;
}
#setup-dialog .setup-tab-btn:hover {
	color: #ffffff;
	background: #1a232c;
	border-color: #2a3a48;
}
#setup-dialog .setup-tab-btn.active {
	color: #ffffff;
	background: #1f2a35;
	border-color: var(--hb-accent);
	border-bottom-color: transparent;
	box-shadow: 0 2px 0 #1f2a35 inset, 0 -1px 0 var(--hb-accent) inset;
}

/* --- Settings: callboard appearance picker --- */
#settings-modal .settings-content {
  background: var(--hb-panel);
  border: 1px solid var(--hb-accent);
  border-radius: 14px;
  color: #fff;
}
#settings-modal .settings-content h2 {
  color: var(--hb-text-accent);
}
#settings-modal .settings-content select:focus,
#settings-modal .settings-content input[type="text"]:focus {
  border-color: var(--hb-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-accent) 22%, transparent);
}
#settings-modal .settings-content input[type="range"]::-webkit-slider-thumb,
#settings-modal .settings-content input[type="range"]::-moz-range-thumb {
  background: var(--hb-accent);
}
#settings-modal .settings-content .btn {
  background: var(--hb-accent);
}
#settings-modal .settings-content .btn:hover {
  background: var(--hb-accent-hover);
}
.hb-tab.active {
  color: var(--hb-text-accent);
  border-color: var(--hb-accent);
}
.hb-theme-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 8px 0 4px;
}
@media (min-width: 720px) {
  .hb-theme-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.hb-theme-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid #2a3a48;
  background: #12161b;
  color: #fff;
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.hb-theme-card:hover {
  border-color: #3a5060;
}
.hb-theme-card.is-selected {
  border-color: var(--hb-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-accent) 28%, transparent);
}
.hb-theme-swatch {
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
}
.hb-theme-card strong {
  font-size: 0.98rem;
  font-weight: 800;
}
.hb-theme-card em {
  font-style: normal;
  font-size: 0.82rem;
  color: #9ab0c0;
  line-height: 1.3;
}
.hb-theme-swatch--classic { background: linear-gradient(135deg, #20a0e0 0 38%, #242526 38% 68%, #141416 68%); }
.hb-theme-swatch--hall { background: linear-gradient(135deg, #e0a020 0 38%, #1c1410 38% 68%, #2a1810 68%); }
.hb-theme-swatch--neon { background: linear-gradient(135deg, #e020a8 0 38%, #0a0612 38% 68%, #c8ff6a 68%); }
.hb-theme-swatch--forest { background: linear-gradient(135deg, #3db87a 0 38%, #101814 38% 68%, #141c18 68%); }

