:root {
  --bg-gradient: linear-gradient(135deg, #1e1e2f 0%, #151522 100%);
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text-primary: #fff;
  --text-secondary: #aaa;
  --accent: #ff007f;
  --accent-hover: #e60072;
  --success: #00ff88;
  --error: #ff3333;
  --warn: #ffcc00;
  
  --c1: #ff3366; /* Red-ish */
  --c2: #33ccff; /* Blue-ish */
  --c3: #00fc9d; /* Green-ish */
  --c4: #ffcc00; /* Yellow */
  --c5: #b166ff; /* Purple */
  --c6: #ffffff; /* White */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
}

body {
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: 0.5px;
}

h1 {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 2rem;
  font-weight: 800;
  background: linear-gradient(90deg, #ff007f, #33ccff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--text-secondary);
  -webkit-text-fill-color: var(--text-secondary);
}

.screen {
  width: 100%;
  max-width: 1000px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.hidden {
  display: none !important;
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 40px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  text-align: center;
  transition: transform 0.3s ease;
}

.glass-panel:hover {
  transform: translateY(-5px);
}

.mode-section {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

.mode-section h2 {
  font-size: 1.5rem;
}

.mode-section p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.divider {
  margin: 30px 0;
  color: var(--text-secondary);
  font-weight: 800;
  letter-spacing: 2px;
}

input {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 20px;
  color: #fff;
  font-size: 1.2rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
  width: 80%;
  max-width: 300px;
}

input:focus {
  border-color: var(--accent);
}

button {
  border: none;
  border-radius: 12px;
  padding: 12px 30px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 80%;
  max-width: 300px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 15px rgba(255, 0, 127, 0.4);
}

.primary-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.secondary-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.highlight {
  font-size: 1.5rem;
  color: #fff;
  font-weight: 800;
  letter-spacing: 2px;
  background: rgba(0, 0, 0, 0.3);
  padding: 5px 15px;
  border-radius: 8px;
  display: inline-block;
  margin-top: 10px;
  user-select: all;
  cursor: pointer;
}

.highlight:hover {
  background: rgba(0,0,0,0.5);
}

.loader {
  border: 4px solid var(--glass-border);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.error-msg {
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 10px;
}

/* --- GAME SCREEN --- */

header {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
  gap: 10px;
}

.player-info {
  display: flex;
  gap: 15px;
  align-items: center;
}

.badge {
  background: var(--accent);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.color-help span {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.game-board {
  display: flex;
  flex-direction: column;
  gap: 30px;
  width: 100%;
}

@media (min-width: 800px) {
  .game-board {
    flex-direction: row;
    align-items: stretch;
  }
}

.board-section {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--glass-border);
}

.board-section h3 {
  text-align: center;
  margin-bottom: 15px;
  color: var(--text-secondary);
}

.history-container {
  flex-grow: 1;
  overflow-y: auto;
  min-height: 250px;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 10px;
}

/* Custom Scrollbar */
.history-container::-webkit-scrollbar {
  width: 6px;
}
.history-container::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 3px;
}

.empty-state {
  text-align: center;
  color: rgba(255, 255, 255, 0.2);
  margin: auto;
  font-style: italic;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
  border-radius: 12px;
  animation: slide-in 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes slide-in {
  0% { transform: translateY(10px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.slots-container {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.color-slot {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.2s, background 0.3s;
}

.color-slot.active {
  box-shadow: 0 0 0 3px var(--accent);
}

.result-pegs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  width: 30px;
  height: 30px;
}

.peg {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}

.peg.hit {
  background: var(--c1);
  box-shadow: 0 0 8px var(--c1);
}

.peg.blow {
  background: var(--text-primary);
  box-shadow: 0 0 8px rgba(255,255,255,0.5);
}

.input-area {
  margin-top: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
  transform: none; /* remove hover effect from parent glass-panel here */
}

.input-area:hover {
  transform: none;
}

.input-area h4 {
  color: var(--text-secondary);
}

.color-palette {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.palette-color {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s, filter 0.2s;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.palette-color:hover {
  transform: scale(1.15);
  filter: brightness(1.2);
}

/* Colors Classes */
.c-0 { background: var(--c1); }
.c-1 { background: var(--c2); }
.c-2 { background: var(--c3); }
.c-3 { background: var(--c4); }
.c-4 { background: var(--c5); }
.c-5 { background: var(--c6); }

/* Opponent Blur */
.opponent-slot {
  width: 25px;
  height: 25px;
  background: rgba(255, 255, 255, 0.2);
}

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade-in 0.3s;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 90%;
  max-width: 400px;
}

.modal-content h2 {
  font-size: 2rem;
  color: var(--accent);
}

.secret-reveal {
  background: rgba(0,0,0,0.3);
  padding: 15px;
  border-radius: 12px;
  margin: 10px 0;
}

.secret-reveal p {
  margin-bottom: 10px;
  color: var(--text-secondary);
}

/* --- New Settings UI --- */

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
  background: rgba(0, 0, 0, 0.2);
  padding: 15px;
  border-radius: 12px;
  margin-bottom: 20px;
  width: 100%;
}

.setting-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.setting-item label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.setting-item select {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid var(--glass-border);
  outline: none;
  font-family: 'Outfit', sans-serif;
}

.setting-item select option {
  background: #1e1e2f;
  color: white;
}

.checkbox-label {
  font-size: 0.9rem;
  color: var(--text-primary) !important;
  cursor: pointer;
  margin-left: 8px;
}

/* --- Turn Indicator --- */
.turn-indicator {
  background: var(--c4);
  color: #000;
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 800;
  box-shadow: 0 0 15px rgba(255, 204, 0, 0.5);
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 10px rgba(255, 204, 0, 0.3); transform: scale(1); }
  50% { box-shadow: 0 0 20px rgba(255, 204, 0, 0.8); transform: scale(1.05); }
  100% { box-shadow: 0 0 10px rgba(255, 204, 0, 0.3); transform: scale(1); }
}

.turn-indicator.opponent {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-secondary);
  box-shadow: none;
  animation: none;
}

/* --- COMPACT MOBILE LAYOUT OVERRIDES --- */

.game-screen-layout {
  padding: 10px !important;
  height: 100vh;
  justify-content: flex-start !important;
  overflow: hidden;
}

.game-header {
  margin-bottom: 5px !important;
  gap: 5px !important;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-header h2 {
  display: none; /* Hide title to save space */
}

.game-board-compact {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
  min-height: 0;
  gap: 10px;
}

.boards-wrapper {
  display: flex;
  flex-direction: row;
  gap: 10px;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.boards-wrapper .board-section {
  padding: 10px;
  border-radius: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.2);
}

.boards-wrapper h3 {
  font-size: 0.9rem;
  margin-bottom: 5px;
  text-align: center;
}

.boards-wrapper .history-container {
  max-height: none;
}

.input-area.glass-panel {
  padding: 10px !important;
  gap: 8px !important;
  margin-top: 0 !important;
  flex-shrink: 0;
}

.color-help {
  font-size: 0.8rem !important;
  margin-bottom: 5px;
  color: var(--text-secondary);
  text-align: center;
}

.compact-btn {
  padding: 8px 16px !important;
  font-size: 1rem !important;
}

/* History row compaction */
.history-row {
  padding: 5px !important;
  gap: 4px !important;
  justify-content: space-evenly !important;
}
.history-row .color-slot {
  width: 20px !important;
  height: 20px !important;
}
.history-row .slots-container {
  gap: 4px !important;
}
.result-pegs {
  width: 20px !important;
  height: 20px !important;
  gap: 2px !important;
}
.peg {
  width: 8px !important;
  height: 8px !important;
}
