/* 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);
}

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

.mode-selector {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-card);
  border-radius: 30px;
  padding: 4px;
  backdrop-filter: blur(10px);
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 10px 18px;
  border-radius: 25px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mode-btn.active {
  background: var(--color-brand-teal);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 150, 136, 0.4);
}

.mode-btn:hover:not(.active) {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

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

.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;
  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: 20px 10px;
  display: grid;
  grid-template-columns: 50px 1fr 60px; /* Left scoring, center pegs, right teal panel */
  gap: 8px;
  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: 15px; /* Spacing between rows */
  width: 100%;
  align-items: center;
}

.decor-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.decor-hole {
  width: 8px;
  height: 8px;
  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: 8px;
}

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

.guess-row {
  display: grid;
  grid-template-columns: 1fr 50px; /* Guesses grid + feedback grid */
  align-items: center;
  padding: 6px 8px;
  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, 1fr);
  gap: 12px;
  justify-items: center;
}

/* --- Sockets (Peg Slots) --- */
.socket {
  width: 32px;
  height: 32px;
  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: 4px;
  justify-content: center;
  align-content: center;
  width: 24px;
  height: 24px;
  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: 3px;
}

.key-hole {
  width: 7px;
  height: 7px;
  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;
}

.shield-container {
  background: var(--color-board-chassis-dark);
  border-radius: 12px;
  padding: 10px;
  position: relative;
  overflow: hidden;
  height: 66px;
  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, 1fr);
  gap: 12px;
  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;
}

/* The Swing Cover Lid */
.shield-lid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-brand-teal);
  background-image: 
    linear-gradient(180deg, var(--color-brand-teal-light) 0%, var(--color-brand-teal-dark) 100%),
    radial-gradient(circle at 50% 0%, rgba(255,255,255,0.15) 0%, transparent 60%);
  border: 2px solid var(--color-brand-teal-dark);
  box-shadow: 
    inset 0 1px 2px rgba(255,255,255,0.25),
    0 4px 8px rgba(0,0,0,0.6);
  border-radius: 8px;
  z-index: 10;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-origin: top;
  backface-visibility: hidden;
}

.shield-lid-handle {
  width: 60px;
  height: 6px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 3px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.shield-lid-text {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}

/* Closed state - resting */
.shield-container.open .shield-lid {
  transform: perspective(800px) rotateX(-120deg);
  box-shadow: 0 15px 25px rgba(0,0,0,0.9);
}

.shield-lid:hover {
  filter: brightness(1.05);
}

/* --- 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 10px 10px 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: 20px 0;
}

.embossed-brand {
  writing-mode: vertical-rl;
  font-weight: 900;
  font-size: 1.5rem;
  letter-spacing: 12px;
  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;
}

/* --- Palette Peg Tray Drawer --- */
.peg-palette {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  padding: 16px 12px;
  box-shadow: inset 0px 4px 10px rgba(0,0,0,0.5);
  border: 1.5px solid rgba(0, 0, 0, 0.3);
}

.palette-peg-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.palette-peg {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease, border-color 0.2s ease;
  border: 2px solid transparent;
}

.palette-peg:hover {
  transform: scale(1.18) translateY(-4px);
  box-shadow: 0px 8px 15px rgba(0,0,0,0.6);
}

.palette-peg.active {
  border-color: #fff;
  transform: scale(1.15) translateY(-2px);
  box-shadow: 
    0px 0px 0px 2px var(--color-brand-teal-light),
    0px 6px 12px rgba(0,0,0,0.5);
}

.color-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* --- Actions Panel & Badge --- */
.status-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  border: 1px solid rgba(255,255,255,0.02);
}

.status-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.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;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.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;
}

/* API Key Settings Panel Styles */
.api-key-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 10px;
}

#api-key-input {
  flex: 1;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1.5px solid var(--border-card);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: border-color 0.2s ease;
}

#api-key-input:focus {
  outline: none;
  border-color: var(--color-brand-teal-light);
}

.save-key-btn {
  padding: 12px 24px !important;
  font-size: 0.95rem !important;
  max-width: 100% !important;
  opacity: 1 !important;
  transform: none !important;
  display: inline-flex !important;
  justify-content: center;
  align-items: center;
}

@media (min-width: 480px) {
  .api-key-group {
    flex-direction: row;
  }
  .save-key-btn {
    width: auto !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;
}

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

.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;
}

.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;
  }
}

/* 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: flex;
  gap: 10px;
  background: rgba(22, 22, 24, 0.96);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  padding: 10px 14px;
  border-radius: 26px;
  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);
}
