/* Mastermind Tactile Board Style Sheet */

/* --- Custom Variables & Tokens --- */
:root {
  --color-board-chassis: #3e3b39;
  --color-board-chassis-dark: #292726;
  --color-board-chassis-light: #4e4a48;
  --color-brand-teal: #009688;
  --color-brand-teal-dark: #00796b;
  --color-brand-teal-light: #26a69a;
  
  --bg-dark: #121212;
  --bg-card: rgba(30, 30, 32, 0.85);
  --border-card: rgba(255, 255, 255, 0.08);
  --text-primary: #ffffff;
  --text-secondary: #a0a0a5;
  --font-family: 'Outfit', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
  
  --shadow-tactile: 0 10px 30px rgba(0, 0, 0, 0.5), 0 1px 8px rgba(255, 255, 255, 0.05);
  --shadow-inset-hole: inset 0px 4px 6px rgba(0,0,0,0.85), 0px 1px 1px rgba(255,255,255,0.15);
}

/* --- Base Body & Backdrop Setup --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(38, 166, 154, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(0, 150, 136, 0.05) 0px, transparent 50%),
    linear-gradient(rgba(18, 18, 18, 0.95), rgba(18, 18, 18, 0.98)),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.01) 0px, rgba(255,255,255,0.01) 1px, transparent 1px, transparent 4px);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-x: hidden;
}

.game-container {
  max-width: 1200px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 25px;
}

/* --- Header & Top Controls --- */
.game-header {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

@media (min-width: 768px) {
  .game-header {
    flex-direction: row;
    justify-content: space-between;
  }
}

.header-logo-group {
  display: flex;
  align-items: center;
  gap: 15px;
}

.game-title {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #ffffff 30%, var(--color-brand-teal-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 10px rgba(0, 150, 136, 0.3);
}

#game-status {
  display: none;
}

.controls-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  position: relative;
}

.utility-btns {
  display: flex;
  gap: 8px;
}

.mobile-menu-btn {
  display: none;
}

@media (min-width: 768px) {
  .mobile-menu-btn {
    display: none !important;
  }

  .utility-btns {
    display: flex !important;
    position: static;
    width: auto;
    min-width: auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }
}

.util-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.util-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.util-btn.reset {
  background: rgba(229, 57, 53, 0.15);
  border-color: rgba(229, 57, 53, 0.3);
  color: #ff8a80;
}

.util-btn.reset:hover {
  background: rgba(229, 57, 53, 0.3);
  color: #fff;
}

/* --- Layout Grid --- */
.game-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
  align-items: start;
}

@media (min-width: 992px) {
  .game-layout {
    grid-template-columns: auto 1fr;
  }
}

/* --- SKEUOMORPHIC BOARD CONTAINER --- */
.board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.mastermind-board {
  position: relative;
  container-type: inline-size;
  background: var(--color-board-chassis-dark);
  border-radius: 24px;
  padding: 18px;
  box-shadow: 
    0 25px 60px rgba(0, 0, 0, 0.8),
    inset 0 4px 6px rgba(255, 255, 255, 0.1),
    inset 0 -4px 6px rgba(0, 0, 0, 0.6);
  border: 4px solid var(--color-board-chassis-light);
  width: 100%;
  max-width: 440px;
  min-width: 320px;
  transition: transform 0.3s ease;
}

.board-body {
  background: var(--color-board-chassis);
  background-image: 
    linear-gradient(180deg, var(--color-board-chassis-light) 0%, var(--color-board-chassis) 100%),
    radial-gradient(circle at 50% 0%, rgba(255,255,255,0.05) 0%, transparent 60%);
  border-radius: 16px;
  padding: 4.55cqw 2.27cqw;
  display: grid;
  grid-template-columns: 11.36cqw 1fr 13.64cqw; /* Left scoring, center pegs, right teal panel */
  gap: 1.82cqw;
  position: relative;
  box-shadow: 
    inset 0 2px 5px rgba(0,0,0,0.5),
    0 2px 4px rgba(255,255,255,0.05);
  border: 2px solid var(--color-board-chassis-dark);
}

/* --- Decor Scoring Side Column --- */
.decor-scoring-column {
  border-right: 1px solid rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-right: 8px;
}

.score-pegs-container {
  display: flex;
  flex-direction: column;
  gap: 3.41cqw; /* Spacing between rows */
  width: 100%;
  align-items: center;
}

.decor-row {
  display: flex;
  flex-direction: column;
  gap: 0.91cqw;
}

.decor-hole {
  width: 1.82cqw;
  height: 1.82cqw;
  border-radius: 50%;
  background: radial-gradient(circle, #151413 30%, #353331 90%);
  box-shadow: var(--shadow-inset-hole);
  opacity: 0.8;
  position: relative;
}

/* Active index pin style */
.decor-hole.active-indicator::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  border: 1px solid var(--color-brand-teal-light);
  animation: pulse-ring 1.5s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.5; }
  100% { transform: scale(1.5); opacity: 0; }
}

.decor-hole.orange-pin {
  background: radial-gradient(circle at 35% 35%, #ff8a80 10%, #e53935 70%, #7f0000 100%);
  box-shadow: 0px 2px 3px rgba(0,0,0,0.6);
}

.decor-hole.white-pin {
  background: radial-gradient(circle at 35% 35%, #ffffff 15%, #e0e0e0 70%, #9e9e9e 100%);
  box-shadow: 0px 2px 3px rgba(0,0,0,0.6);
}

/* --- Center Grid (Guess Rows) --- */
.center-grid {
  display: flex;
  flex-direction: column;
  gap: 1.82cqw;
}

.rows-container {
  display: flex;
  flex-direction: column-reverse; /* Play from bottom to top! */
  gap: 2.05cqw;
}

.guess-row {
  display: grid;
  grid-template-columns: 1fr 11.36cqw; /* Guesses grid + feedback grid */
  align-items: center;
  padding: 1.36cqw 1.82cqw;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.02);
  transition: all 0.3s ease;
  position: relative;
}

.guess-row.active {
  background: rgba(0, 150, 136, 0.06);
  border: 1px solid rgba(0, 150, 136, 0.25);
  box-shadow: 0 0 10px rgba(0, 150, 136, 0.15);
}

.guess-row.active::before {
  content: '👉';
  position: absolute;
  left: -22px;
  font-size: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  animation: bounce-left 1s infinite alternate;
}

@keyframes bounce-left {
  0% { transform: translateY(-50%) translateX(0); }
  100% { transform: translateY(-50%) translateX(-4px); }
}

.guess-sockets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
  justify-items: center;
}

/* --- Sockets (Peg Slots) --- */
.socket {
  width: 7.27cqw;
  height: 7.27cqw;
  border-radius: 50%;
  background: radial-gradient(circle, #1a1817 20%, #3e3b39 90%);
  box-shadow: var(--shadow-inset-hole);
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease, border 0.2s ease;
  border: 1.5px solid rgba(0,0,0,0.4);
}

.guess-row.active .socket {
  border-color: rgba(255, 255, 255, 0.08);
}

.guess-row.active .socket:hover {
  transform: scale(1.08);
  border-color: var(--color-brand-teal-light);
}

/* 3D Peg Styling inside Socket */
.peg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 
    0px 4px 6px rgba(0,0,0,0.5), 
    inset 0px -2px 3px rgba(0,0,0,0.3);
  animation: peg-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  pointer-events: none;
}

@keyframes peg-pop {
  0% { transform: scale(0.4); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Colors radial gradients definitions */
.color-red {
  background: radial-gradient(circle at 35% 35%, #ff8a80 8%, #e53935 55%, #b71c1c 90%, #7f0000 100%);
}
.color-orange {
  background: radial-gradient(circle at 35% 35%, #ffcc80 8%, #f57c00 55%, #e65100 90%, #9e3600 100%);
}
.color-yellow {
  background: radial-gradient(circle at 35% 35%, #ffff8d 8%, #fbc02d 55%, #f57f17 90%, #b25800 100%);
}
.color-green {
  background: radial-gradient(circle at 35% 35%, #a7ffeb 8%, #00b0ff 10%, #009688 55%, #004d40 95%);
  /* Classic teal-green matches image */
  background: radial-gradient(circle at 35% 35%, #80cbc4 8%, #00897b 55%, #004d40 90%, #002c24 100%);
}
.color-blue {
  background: radial-gradient(circle at 35% 35%, #80d8ff 8%, #0288d1 55%, #01579b 90%, #003663 100%);
}
.color-purple {
  background: radial-gradient(circle at 35% 35%, #ea80fc 8%, #8e24aa 55%, #4a148c 90%, #2f065c 100%);
}

/* --- Feedback Grid (2x2 small key pegs) --- */
.feedback-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 0.91cqw;
  justify-content: center;
  align-content: center;
  width: 5.45cqw;
  height: 5.45cqw;
  margin-left: auto;
  border-radius: 4px;
  background: rgba(0,0,0,0.25);
  box-shadow: inset 1px 1px 3px rgba(0,0,0,0.5);
  padding: 0.68cqw;
}

.key-hole {
  width: 1.59cqw;
  height: 1.59cqw;
  border-radius: 50%;
  background: radial-gradient(circle, #100f0f 30%, #302e2c 90%);
  box-shadow: inset 0px 1px 2px rgba(0,0,0,0.9);
}

/* Feedback pegs key values */
.key-peg-red {
  background: radial-gradient(circle at 35% 35%, #ff8a80 15%, #d32f2f 70%, #7f0000 100%);
  box-shadow: 0px 1px 2px rgba(0,0,0,0.8);
}

.key-peg-white {
  background: radial-gradient(circle at 35% 35%, #ffffff 15%, #e0e0e0 70%, #9e9e9e 100%);
  box-shadow: 0px 1px 2px rgba(0,0,0,0.8);
}

/* --- Dividing Lines & Spacing --- */
.dividing-line {
  height: 4px;
  background: var(--color-board-chassis-dark);
  border-bottom: 1.5px solid rgba(255,255,255,0.08);
  border-top: 1.5px solid rgba(0,0,0,0.4);
  margin: 6px 0;
  border-radius: 2px;
}

/* --- BOTTOM SHIELD SECTION --- */
.shield-section-wrapper {
  margin-top: 2px;
  position: relative;
  z-index: 0;
}

.secret-code-prompt {
  display: none;
}

.secret-setup-active .secret-code-prompt {
  display: block;
  margin-bottom: 1.82cqw;
  color: #ff6b6b;
  font-size: clamp(0.95rem, 2.4cqw, 1.15rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  text-shadow: 0 0 18px rgba(255, 107, 107, 0.35);
  animation: secret-prompt-pulse 1.2s ease-in-out infinite alternate;
}

.secret-setup-active .game-header,
.secret-setup-active .rows-container,
.secret-setup-active .decor-scoring-column,
.secret-setup-active .side-brand-panel,
.secret-setup-active .sidebar-controls,
.secret-setup-active #solver-choice-container,
.secret-setup-active #btn-auto-solve,
.secret-setup-active #btn-new-game {
  opacity: 0.28;
  transition: opacity 0.25s ease;
}

.secret-setup-active .shield-section-wrapper {
  z-index: 2;
}

.secret-setup-active .shield-container {
  box-shadow:
    0 0 0 2px rgba(255, 107, 107, 0.8),
    0 0 24px rgba(255, 107, 107, 0.22),
    inset 0px 3px 6px rgba(0,0,0,0.8);
}

.secret-setup-active .secret-socket {
  box-shadow:
    var(--shadow-inset-hole),
    0 0 0 1px rgba(255, 107, 107, 0.4),
    0 0 14px rgba(255, 107, 107, 0.18);
}

@keyframes secret-prompt-pulse {
  from {
    transform: translateY(0);
    opacity: 0.75;
  }
  to {
    transform: translateY(-2px);
    opacity: 1;
  }
}

.shield-container {
  background: var(--color-board-chassis-dark);
  border-radius: 12px;
  padding: 2.27cqw;
  position: relative;
  min-height: 15cqw;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0px 3px 6px rgba(0,0,0,0.8);
}

.shield-sockets-box {
  width: 100%;
}

.shield-sockets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
  justify-items: center;
}

.secret-socket.locked::after {
  content: '🔒';
  font-size: 0.65rem;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.5;
}

/* --- Teal Embossed BRAND PANEL --- */
.side-brand-panel {
  background: var(--color-brand-teal);
  background-image: 
    linear-gradient(90deg, var(--color-brand-teal-dark) 0%, var(--color-brand-teal) 50%, var(--color-brand-teal-light) 100%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.01) 0px, rgba(255,255,255,0.01) 1px, transparent 1px, transparent 6px);
  border-radius: 0 2.27cqw 2.27cqw 0;
  border: 1px solid var(--color-brand-teal-dark);
  box-shadow: 
    inset 2px 0 5px rgba(255,255,255,0.2),
    inset -2px 0 5px rgba(0,0,0,0.5),
    2px 2px 5px rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4.55cqw 0;
}

.embossed-brand {
  writing-mode: vertical-rl;
  font-weight: 900;
  font-size: clamp(1rem, 3.41cqw, 1.5rem);
  letter-spacing: 2.73cqw;
  color: var(--color-brand-teal);
  transform: rotate(180deg);
  user-select: none;
  
  /* HIGH-FIDELITY EMBOSSING SHADOW */
  text-shadow: 
    -1px -1px 0px rgba(0, 0, 0, 0.85),
    1px 1px 0px rgba(255, 255, 255, 0.25);
  opacity: 0.95;
  text-align: center;
}

/* --- SIDEBAR PANEL & DOCKS --- */
.sidebar-controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.control-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow-tactile);
  backdrop-filter: blur(16px);
}

.control-card h2 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  border-left: 4px solid var(--color-brand-teal);
  padding-left: 10px;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.4;
}

.status-badge {
  font-size: 0.85rem;
  font-weight: 800;
  background: rgba(0, 150, 136, 0.15);
  color: var(--color-brand-teal-light);
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.status-badge.waiting {
  background: rgba(251, 192, 45, 0.15);
  color: #fbc02d;
}

.status-badge.danger {
  background: rgba(229, 57, 53, 0.15);
  color: #ff8a80;
}

.primary-action-btn {
  background: linear-gradient(135deg, var(--color-brand-teal) 0%, var(--color-brand-teal-dark) 100%);
  color: #fff;
  border: none;
  font-family: var(--font-family);
  font-weight: 700;
  font-size: 1rem;
  padding: 15px 32px;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 150, 136, 0.35);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 280px;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: scale(0.9) translateY(10px);
  opacity: 0;
}

.primary-action-btn.visible {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.primary-action-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 8px 25px rgba(0, 150, 136, 0.45);
}

.primary-action-btn:active {
  transform: translateY(0);
}

.primary-action-btn:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.2);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* Split button layouts for solver & LLM selection */
.action-btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 440px;
  align-items: center;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: scale(0.9) translateY(10px);
  opacity: 0;
}

.action-btn-group.visible {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.split-btn {
  width: 100% !important;
  max-width: 280px !important;
  transform: none !important;
  opacity: 1 !important;
  display: flex !important;
}

@media (min-width: 480px) {
  .action-btn-group {
    flex-direction: row;
    justify-content: center;
  }
  .split-btn {
    width: 200px !important;
  }
}

.llm-theme {
  background: linear-gradient(135deg, #7b1fa2 0%, #4a148c 100%) !important;
  box-shadow: 0 6px 20px rgba(123, 31, 162, 0.35) !important;
}

.llm-theme:hover {
  box-shadow: 0 8px 25px rgba(123, 31, 162, 0.45) !important;
  filter: brightness(1.15) !important;
}

.secondary-action-btn {
  background: rgba(38, 166, 154, 0.15);
  color: var(--color-brand-teal-light);
  border: 1.5px solid rgba(38, 166, 154, 0.4);
  font-family: var(--font-family);
  font-weight: 700;
  font-size: 1rem;
  padding: 15px 32px;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 150, 136, 0.15);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 280px;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease, border-color 0.2s ease;
  transform: scale(0.9) translateY(10px);
  opacity: 0;
}

#btn-new-game {
  margin-top: 4px;
  align-self: center;
}

.secondary-action-btn.visible {
  transform: scale(1) translateY(0);
  opacity: 1;
}

#btn-auto-solve.visible:not(:disabled):not(.loading) {
  animation: solve-btn-bounce 1.5s ease-in-out infinite;
}

.secondary-action-btn:hover:not(:disabled) {
  background: rgba(38, 166, 154, 0.25);
  border-color: var(--color-brand-teal-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 150, 136, 0.25);
}

.secondary-action-btn:active:not(:disabled) {
  transform: translateY(0);
}

.secondary-action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.secondary-action-btn.loading {
  position: relative;
  padding-left: 48px;
}

.secondary-action-btn.loading::before {
  content: '';
  position: absolute;
  left: 18px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--color-brand-teal-light);
  animation: llm-spin 0.8s linear infinite;
}

.status-badge.loading {
  position: relative;
  padding-right: 30px;
}

.status-badge.loading::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: currentColor;
  animation: llm-spin 0.8s linear infinite;
}

@keyframes llm-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes solve-btn-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

.hidden {
  display: none !important;
}

/* --- Conversational Console Log --- */
.terminal-console {
  background: rgba(10, 10, 12, 0.95);
  border-radius: 16px;
  height: 220px;
  overflow-y: auto;
  padding: 15px;
  font-family: var(--font-family); /* Modern readable UI instead of monospace */
  font-size: 0.85rem;
  line-height: 1.4;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0px 4px 16px rgba(0, 0, 0, 0.8), 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: height 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 992px) {
  .terminal-console {
    height: 480px;
  }
}

@media (max-width: 767px) {
  body {
    align-items: flex-start;
    padding: 16px;
  }

  .game-container {
    gap: 20px;
  }

  .game-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .header-logo-group {
    flex-direction: row;
    align-items: center;
    gap: 0;
    min-width: 0;
    flex: 1;
  }

  .game-title {
    font-size: 1.8rem;
    letter-spacing: 3px;
  }

  .controls-panel,
  .utility-btns {
    width: 100%;
    min-width: 0;
  }

  .controls-panel {
    justify-content: flex-end;
    width: auto;
    flex: 0 0 auto;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    white-space: nowrap;
  }

  .utility-btns {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(220px, 70vw);
    min-width: 0;
    display: none;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-radius: 16px;
    border: 1px solid var(--border-card);
    background: rgba(22, 23, 24, 0.96);
    box-shadow: var(--shadow-tactile);
    backdrop-filter: blur(14px);
    z-index: 30;
  }

  .utility-btns.open {
    display: flex;
  }

  .utility-btns .util-btn {
    width: 100%;
    min-width: 0;
    justify-content: center;
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .game-layout {
    gap: 22px;
  }

  .board-wrapper {
    gap: 16px;
  }

  .mastermind-board {
    min-width: 0;
    max-width: 100%;
    padding: 12px;
  }

  .board-body {
    grid-template-columns: 34px minmax(0, 1fr) 40px;
    gap: 6px;
    padding: 14px 8px;
  }

  .center-grid,
  .rows-container,
  .guess-sockets {
    min-width: 0;
  }

  .guess-sockets,
  .shield-sockets {
    justify-content: center;
  }

  .action-btn-group,
  .secondary-action-btn {
    max-width: 100%;
  }

  .sidebar-controls .control-card {
    padding: 18px;
  }

  .terminal-console {
    height: 200px;
    padding: 12px;
  }

  .console-line {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  body {
    padding: 8px;
  }

  .game-container {
    width: calc(100vw - 16px);
  }

  .game-title {
    font-size: 1.65rem;
    letter-spacing: 2.5px;
  }

  .utility-btns {
    width: min(220px, calc(100vw - 16px));
  }

  .mobile-menu-btn {
    width: auto;
  }

  .mastermind-board {
    width: 100%;
    padding: 10px;
    border-width: 3px;
  }

  .board-body {
    grid-template-columns: 26px minmax(0, 1fr);
    padding: 10px 4px;
  }

  .decor-scoring-column {
    padding-right: 6px;
  }

  .guess-sockets,
  .shield-sockets {
    justify-content: center;
  }

  .side-brand-panel {
    display: none;
  }

  .control-card {
    padding: 16px;
  }

  .terminal-console {
    height: 180px;
  }
}

/* Scrollbar customization for console */
.terminal-console::-webkit-scrollbar {
  width: 6px;
}
.terminal-console::-webkit-scrollbar-track {
  background: transparent;
}
.terminal-console::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
.terminal-console::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.console-line {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  animation: bubbleSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  word-break: break-word;
  position: relative;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

@keyframes bubbleSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Left Aligned - LLM/Solver Feedback */
.console-line.llm-msg {
  align-self: flex-start;
  background: linear-gradient(135deg, rgba(81, 45, 168, 0.35) 0%, rgba(103, 58, 183, 0.2) 100%);
  border: 1px solid rgba(149, 117, 205, 0.35);
  color: #e1d8f5;
  border-bottom-left-radius: 4px;
}

/* Right Aligned - Game States / Feedback */
.console-line.game-state-msg {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(0, 121, 107, 0.35) 0%, rgba(0, 150, 136, 0.2) 100%);
  border: 1px solid rgba(77, 182, 172, 0.35);
  color: #e0f2f1;
  border-bottom-right-radius: 4px;
}

/* Centered - General System / Platform Notices */
.console-line.system-msg {
  align-self: center;
  max-width: 90%;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 4px 8px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-align: center;
  font-family: var(--font-family);
  font-weight: 500;
  letter-spacing: 0.3px;
  opacity: 0.85;
}

/* Center Aligned - Error Message */
.console-line.error-msg {
  align-self: center;
  max-width: 90%;
  background: linear-gradient(135deg, rgba(211, 47, 47, 0.25) 0%, rgba(198, 40, 40, 0.15) 100%);
  border: 1px solid rgba(239, 83, 80, 0.4);
  color: #ffcdd2;
  border-radius: 12px;
  text-align: center;
}

/* Special Center Aligned - Victory */
.console-line.victory-msg {
  align-self: center;
  max-width: 90%;
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.35) 0%, rgba(139, 195, 74, 0.25) 100%);
  border: 1px solid rgba(139, 195, 74, 0.5);
  color: #e8f5e9;
  border-radius: 16px;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.2);
}

/* Special Center Aligned - Defeat */
.console-line.defeat-msg {
  align-self: center;
  max-width: 90%;
  background: linear-gradient(135deg, rgba(244, 67, 54, 0.35) 0%, rgba(229, 57, 53, 0.25) 100%);
  border: 1px solid rgba(239, 83, 80, 0.5);
  color: #ffebee;
  border-radius: 16px;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 4px 15px rgba(244, 67, 54, 0.2);
}

/* Conversation Components inside Bubbles */
.bubble-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 800;
  opacity: 0.6;
  margin-bottom: 2px;
}

/* 1. Mini Peg Row Styles */
.mini-pegs-container {
  display: flex;
  gap: 8px;
  padding: 4px 0;
}

.mini-peg {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), inset 0px -1px 2px rgba(0, 0, 0, 0.4);
  position: relative;
}

.mini-peg.peg-red {
  background: radial-gradient(circle at 35% 35%, #ff8a80 8%, #e53935 55%, #b71c1c 90%, #7f0000 100%);
}
.mini-peg.peg-orange {
  background: radial-gradient(circle at 35% 35%, #ffcc80 8%, #f57c00 55%, #e65100 90%, #9e3600 100%);
}
.mini-peg.peg-yellow {
  background: radial-gradient(circle at 35% 35%, #ffff8d 8%, #fbc02d 55%, #f57f17 90%, #b25800 100%);
}
.mini-peg.peg-green {
  background: radial-gradient(circle at 35% 35%, #80cbc4 8%, #00897b 55%, #004d40 90%, #002c24 100%);
}
.mini-peg.peg-blue {
  background: radial-gradient(circle at 35% 35%, #80d8ff 8%, #0288d1 55%, #01579b 90%, #003663 100%);
}
.mini-peg.peg-purple {
  background: radial-gradient(circle at 35% 35%, #ea80fc 8%, #8e24aa 55%, #4a148c 90%, #2f065c 100%);
}

/* 2. Key Pegs Row Styles */
.key-pegs-row {
  display: flex;
  gap: 6px;
  padding: 4px 0;
  align-items: center;
}

.mini-key-peg {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.mini-key-peg.red-key {
  background: radial-gradient(circle at 35% 35%, #ff8a80 15%, #d32f2f 70%, #7f0000 100%);
}

.mini-key-peg.white-key {
  background: radial-gradient(circle at 35% 35%, #ffffff 15%, #e0e0e0 70%, #9e9e9e 100%);
}

.no-key-pegs {
  font-size: 0.75rem;
  opacity: 0.7;
  font-style: italic;
}

/* 3. Thoughts bubble block */
.thoughts-quote {
  font-style: italic;
  font-size: 0.8rem;
  border-left: 2px solid rgba(149, 117, 205, 0.6);
  padding-left: 10px;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.4;
}

/* 4. Pulsating thinking row */
.thinking-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #9575cd;
  animation: pulseAnimation 1.2s infinite ease-in-out;
}

@keyframes pulseAnimation {
  0% {
    transform: scale(0.8);
    opacity: 0.4;
    box-shadow: 0 0 0 0 rgba(149, 117, 205, 0.7);
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
    box-shadow: 0 0 0 4px rgba(149, 117, 205, 0);
  }
  100% {
    transform: scale(0.8);
    opacity: 0.4;
    box-shadow: 0 0 0 0 rgba(149, 117, 205, 0);
  }
}

/* 5. Shrunk Possibilities Row */
.shrunk-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.shrunk-num {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  opacity: 0.8;
}

.shrunk-num.highlighted {
  color: #4db6ac;
  font-weight: bold;
  opacity: 1;
}

.shrunk-arrow {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.9rem;
}

.shrunk-label {
  font-size: 0.7rem;
  opacity: 0.6;
  text-transform: uppercase;
}

/* --- Rules Modal Overlay --- */
.rules-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.rules-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.rules-modal {
  background: #1e1e20;
  border: 1px solid var(--border-card);
  border-radius: 24px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-tactile);
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.rules-modal-overlay.open .rules-modal {
  transform: scale(1);
}

.rules-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-card);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rules-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
}

.close-modal-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
}

.close-modal-btn:hover {
  color: #fff;
}

.rules-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  line-height: 1.6;
}

.rules-body h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-brand-teal-light);
  margin-top: 10px;
}

.rules-body p {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.rules-body ul {
  padding-left: 20px;
  font-size: 0.92rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bullet {
  font-size: 1.1rem;
  line-height: 1;
  vertical-align: middle;
}
.bullet.red { color: #e53935; }
.bullet.white { color: #ffffff; text-shadow: 0 0 2px rgba(255,255,255,0.8); }

.disclaimer {
  font-style: italic;
  font-size: 0.85rem !important;
  color: #88888b !important;
  background: rgba(0,0,0,0.15);
  padding: 10px;
  border-radius: 8px;
  margin-top: 10px;
}

/* --- Floating Color Picker Popout --- */
.color-picker-popout {
  position: absolute;
  display: grid;
  grid-template-columns: repeat(3, 30px);
  gap: 10px;
  background: rgba(22, 22, 24, 0.96);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  padding: 12px;
  border-radius: 22px;
  box-shadow: 
    0 15px 35px rgba(0, 0, 0, 0.75),
    inset 0 1px 1px rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(16px);
  z-index: 1000;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform: translate(-50%, -125%) scale(0.95);
  opacity: 0;
  pointer-events: none;
}

.color-picker-popout.open {
  transform: translate(-50%, -125%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.color-picker-popout::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: rgba(22, 22, 24, 0.96) transparent;
  display: block;
  width: 0;
}

.picker-peg {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 
    0px 3px 5px rgba(0,0,0,0.5), 
    inset 0px -1px 2px rgba(0,0,0,0.3);
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.15s ease;
}

.picker-peg:hover {
  transform: scale(1.22) translateY(-2px);
  box-shadow: 0px 6px 12px rgba(0,0,0,0.6);
}

.picker-peg:active {
  transform: scale(1.1);
}

/* --- Embedded mode (running inside the slide deck) ---
   Set by the inline script in index.html. The game is laid out at a fixed
   16:9 design size (1352x760, or taller if its content needs it) and scaled
   uniformly to fit the frame, centred, so proportions never change.
   embed.js sets --embed-scale/x/y. Direct visits are unaffected. */
html.embedded,
html.embedded body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

html.embedded body {
  display: block;
  padding: 0;
  min-height: 0;
}

html.embedded .game-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 1352px;
  max-width: none;
  min-height: 760px;
  margin: 0;
  padding: 0;
  transform-origin: 0 0;
  transform: translate(var(--embed-x, 0px), var(--embed-y, 0px)) scale(var(--embed-scale, 1));
}

/* The colour picker moves inside the scaled container (see embed.js),
   so it scales with the board. The rules modal sits outside it and is
   zoomed by the same factor. */
html.embedded .rules-modal {
  zoom: var(--embed-scale, 1);
  /* vh units get zoomed too, so divide them back out to keep it on screen */
  max-height: calc(85vh / var(--embed-scale, 1));
}
