/* =========================
   LAYOUT / BASE THEME
   ========================= */

:root{ --gap:8px; --radius:12px; }
*{ box-sizing:border-box; }

body{
  margin:0; background:#0b1020; color:#e5e7eb;
  font-family:system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.topbar{
  padding:12px 16px; border-bottom:1px solid #1f2233; background:#0d1326;
}
.brand{ font-weight:800; margin-bottom:8px; }

.controls{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.spacer{ flex:1; }
.mp-input{
  height:36px;
  min-width:88px;
  max-width:130px;
  border:1px solid #cbd5e1;
  border-radius:8px;
  padding:0 10px;
  font:600 14px/1 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
.mp-input.room-code{
  max-width:96px;
  text-transform:uppercase;
}
.mp-status{
  min-width:120px;
  color:#cbd5e1;
  font-size:13px;
  font-weight:700;
}
.hidden{ display:none !important; }
.mp-players{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  padding:8px 0 0;
}
.mp-player{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:128px;
  padding:7px 10px;
  border:2px solid var(--player-color, #334155);
  border-radius:8px;
  background:var(--player-bg, #111827);
  color:var(--player-text, #dbeafe);
  font-size:13px;
}
.mp-player.me{
  box-shadow:0 0 0 2px rgba(255,255,255,.85);
}
.mp-player.turn{
  outline:3px solid var(--player-color, #1f8a4c);
  outline-offset:2px;
}
.mp-player.offline{
  opacity:.58;
  background:#1f2937;
}
.mp-player.offline.turn{
  background:#374151;
  color:#d1d5db;
}
.mp-player-name{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.mp-player-score{
  margin-left:auto;
  font-size:16px;
}
.daily-word{ display:flex; align-items:center; gap:10px; font-weight:700; color:#cbd5e1; }
#dailyWordText{ cursor:pointer; text-decoration:underline; }
.daily-word .daily-high{ font-weight:600; opacity:.9; }

.container{ padding:16px; max-width:1100px; margin:0 auto; }

.headers, .board{ display:grid; gap:var(--gap); }

/* Column headers */
.hcell{
  background:#fff59d; color:#1f2937;
  font-weight:800; text-align:center;
  padding:12px; border-radius:12px;
  font-size:18px;
  letter-spacing:0.5px;
}

/* Cells */
.cell{
  background:#fff; color:#000; border-radius:var(--radius);
  display:flex; align-items:center; justify-content:center; padding:6px;
  aspect-ratio:1/1;
  overflow:hidden;
  position:relative;
}

/* Word input */
.cell input{
  width:100%;
  height:auto;
  min-height:1.1em;
  border:none; outline:none; background:transparent;
  padding:0;
  min-width:0;
  text-align:center; font-weight:800; font-size:18px;
  line-height:1;
  color:inherit;
}

/* IPA under word (when enabled) */
.ipa{
  max-width:100%;
  font-size:clamp(10px, 2.4vw, 18px);
  font-weight:600;
  line-height:1.05;
  color:#1f2937;
  margin-top:1px;
  overflow-wrap:anywhere;
  text-align:center;
}
.ipa { cursor:pointer; }
.ipa::after { content:" 🔊"; opacity:0.5; font-size:0.9em; }

.cell .cell-ipa{
  font-size:clamp(9px, 2.1vw, 13px);
  line-height:1;
  margin-top:0;
  max-height:2.2em;
  overflow:hidden;
}

.cell .cell-ipa::after{
  font-size:.58em;
  margin-left:2px;
}

.speak-col{ cursor:pointer; margin-left:6px; opacity:.75; }
.speak-col:hover{ opacity:1; }

/* Hint UI */
.hint-item{ padding:6px 8px; cursor:pointer; border-bottom:1px solid #eee; }
.hint-item:hover{ background:#faf6d8; }

.hint-button,
.hint-icon{
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:22px; height:22px;
  border-radius:50%;
  border:2px solid black;
  background-color:#fffa;
  box-shadow:0 0 3px rgba(0,0,0,0.2);
  cursor:pointer;
}
.hint-button:hover,
.hint-icon:hover{
  background-color:#fff47a;
  box-shadow:0 0 4px rgba(0,0,0,0.4);
}

/* =========================
   ENGINE BACKGROUND STATES
   ========================= */

.cell.empty { background:#ffffff; color:#000; }
.cell.good  { background:#FFD966; }                 /* light orange */
.cell.light { background:#d9fbe1; }                 /* column subset bonus (10) */
.cell.deep  { background:#1f8a4c; color:#e5ffee; }  /* left subset bonus (20) */
.cell.novel { background:#2ff000; }                 /* novel grapheme */
.board .cell.cell-owned{
  outline:4px solid var(--owner-color, #2563eb);
  outline-offset:-4px;
}
.cell.cell-blocked{
  background:#e5e7eb !important;
  color:#64748b !important;
  box-shadow:inset 0 0 0 2px #cbd5e1 !important;
}
.cell.cell-blocked input{
  cursor:not-allowed;
  color:#64748b !important;
  -webkit-text-fill-color:#64748b !important;
}
.board .cell.cell-current-turn{
  background:#fff7bf !important;
  box-shadow:
    inset 0 0 0 4px #f59e0b,
    0 0 0 2px rgba(245,158,11,.25),
    0 4px 12px rgba(245,158,11,.25) !important;
}
.board .cell.cell-waiting-turn{
  background:#f8fafc !important;
  color:#475569 !important;
  box-shadow:
    inset 0 0 0 3px #facc15,
    0 0 0 2px rgba(250,204,21,.18) !important;
}
.turn-waiting-label{
  width:100%;
  padding:0 4px;
  text-align:center;
  color:#475569;
  font-size:clamp(9px, 2.6vw, 13px);
  font-weight:900;
  line-height:1.1;
  overflow-wrap:anywhere;
  pointer-events:none;
}
.cell-waiting-turn input{
  display:none;
}
.cell-pass-btn{
  position:absolute;
  right:4px;
  bottom:4px;
  z-index:3;
  min-width:0;
  min-height:0 !important;
  padding:3px 5px;
  border:0 !important;
  border-radius:6px;
  background:#0f766e !important;
  color:#ecfeff !important;
  font-size:10px;
  font-weight:900;
  line-height:1;
  box-shadow:0 1px 4px rgba(15,23,42,.25);
}
.cell-pass-btn:hover{
  filter:brightness(1.08);
}

@media (max-width: 640px){
  .board .cell.cell-current-turn{
    overflow:visible;
    z-index:4;
  }

  .cell-pass-btn{
    top:-8px;
    right:-6px;
    bottom:auto;
    min-height:18px !important;
    padding:2px 5px;
    border-radius:999px;
    font-size:9px;
    line-height:1;
    box-shadow:0 1px 5px rgba(15,23,42,.28);
  }
}

/* =========================
   SOUND / WORD BONUS BACKGROUNDS
   (yellow family)
   ========================= */

.cell.cell-bonus-partial{
  background:#fff6b0 !important;   /* light yellow */
}

.cell.cell-bonus-full{
  background:#fff000 !important;   /* bright yellow */
}

.cell.cell-bonus-combo{
  background: linear-gradient(135deg, #fff000, #ffb74d) !important;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.2);
}

/* Bonus backgrounds are LIGHT -> ensure readable dark text */
.cell.cell-bonus-partial,
.cell.cell-bonus-full,
.cell.cell-bonus-combo{
  color:#111 !important;
}

/* Ensure input & ipa follow cell color (unless freq classes override) */
.cell.cell-bonus-partial input,
.cell.cell-bonus-full input,
.cell.cell-bonus-combo input{
  color:inherit !important;
}
.cell.cell-bonus-partial .ipa,
.cell.cell-bonus-full .ipa,
.cell.cell-bonus-combo .ipa{
  color:inherit !important;
}

/* =========================
   ANAGRAM + SOUND => ORANGE
   If cell has .cell-anag AND any sound bonus class, force orange.
   ========================= */

.board .cell.cell-anag.cell-bonus-partial,
.board .cell.cell-anag.cell-bonus-full{
  background: #F0BF0A !important; /* Orange*/
  color:#fff7ed !important;
}
.board .cell.cell-anag.cell-bonus-combo{
  background:#b45309 !important;
  color:#fff7ed !important;
}
.board .cell.cell-anag.cell-bonus-combo input,
.board .cell.cell-anag.cell-bonus-combo .ipa{
  color:#fff7ed !important;
}

/* keep text readable */
.board .cell.cell-anag.cell-bonus-partial input,
.board .cell.cell-anag.cell-bonus-full input,
.board .cell.cell-anag.cell-bonus-partial .ipa,
.board .cell.cell-anag.cell-bonus-full .ipa{
  color:#fff7ed !important;
}



/* DARK green for anagram word cell */
.board .cell.cell-anag-word{
  background:#1f8a4c !important;   /* match your deep green */
  color:#e5ffee !important;
}
/* LIGHT green for anagram column */
/* Column anagram must stay light green even if legacy .cell-anag is present */
.board .cell.cell-anag-col{
  background:#c8e6c9 !important;
  color:#111 !important;
}
/* If anagram word also has bonus classes, keep it dark green (override yellow) */
.board .cell.cell-anag-word.cell-bonus-partial,
.board .cell.cell-anag-word.cell-bonus-full,
.board .cell.cell-anag-word.cell-bonus-combo{
  background:#1f8a4c !important;
  color:#e5ffee !important;
}
.board .cell.cell-anag-word.cell-bonus-partial input,
.board .cell.cell-anag-word.cell-bonus-full input,
.board .cell.cell-anag-word.cell-bonus-combo input{
  color:#e5ffee !important;
}
.board .cell.cell-anag-word .ipa{ color:#e5ffee !important; }

/* Legacy: if you still emit .cell-anag on the word cell */
.board .cell.cell-anag{
  background:#1f8a4c !important;
  color:#e5ffee !important;
}
.board .cell.cell-anag input,
.board .cell.cell-anag .ipa{
  color:#e5ffee !important;
}

/* keep chips readable */
.cell .chip{ color:inherit; }

/* =========================
   SCORE STACK / DEBUG
   ========================= */

.cell-wrap{ position:relative; }

.score-stack{
  position:absolute; left:4px; top:4px;
  z-index:2;
  display:flex; flex-direction:column; gap:1px;
  max-width:calc(100% - 8px);
  font:8px/1.05 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  opacity:.95;
  pointer-events:none;
}

.score-stack .chip{
  max-width:100%;
  padding:1px 3px;
  border-radius:5px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.score-chip-row{
  padding:2px 6px;
  border-radius:999px;
  min-width:40px;
  text-align:center;
  white-space:nowrap;
  box-shadow:0 1px 0 rgba(0,0,0,.06);
}

.score-row-w{ background:#DCFCE7; color:#065F46; }
.score-row-s{ background:#FEFCE8; color:#713F12; }
.score-row-a{
  background:#fff; color:#065F46;
  border:1px solid #34D399;
}

.debug-line{
  font-size:12px;
  opacity:.75;
  margin-top:2px;
  white-space:nowrap;
}
.debug-line code{
  background:rgba(0,0,0,.05);
  padding:0 4px;
  border-radius:4px;
}

/* =========================
   MODAL / BUTTONS
   ========================= */

button{
  background:#243b8a; color:#e5e7eb;
  border:none; padding:8px 12px;
  border-radius:8px; cursor:pointer;
}
button:hover{ filter:brightness(1.1); }

.modal.hidden{ display:none; }
.modal{
  position:fixed; inset:0;
  background:rgba(0,0,0,.55);
  display:grid; place-items:center;
  z-index:1000;
}
.modal-card{
  width:min(560px, 92vw);
  background:#0f172a;
  border:1px solid #334155;
  border-radius:12px;
  box-shadow:0 12px 32px rgba(0,0,0,.45);
  overflow:hidden;
}
.modal-header{
  display:flex; justify-content:space-between; align-items:center;
  padding:10px 12px;
  border-bottom:1px solid #1f2937;
  background:#111827;
}
.modal-title{ font-weight:800; }
.modal-close{
  background:transparent; color:#e5e7eb;
  border:none; font-size:22px; cursor:pointer;
}
.modal-body{ padding:12px 14px; line-height:1.45; }
.modal-body ul{ margin:0; padding-left:18px; }
.modal-body li{ margin:6px 0; }

.message-card{
  width:min(360px, calc(100vw - 36px));
  border:1px solid #f59e0b;
  border-radius:10px;
  box-shadow:0 16px 36px rgba(15,23,42,.22);
}
.message-card .modal-header{
  background:#fff7ed;
  color:#7c2d12;
  padding:8px 10px;
}
#messageBody{
  color:#111827;
  font-size:.95rem;
  padding:10px 12px 12px;
}
#messageModal{
  background:rgba(15,23,42,.18);
  align-items:center;
}
#messageModal .modal-close{
  color:#7c2d12;
  font-size:20px;
}

.hint-list{ display:flex; flex-wrap:wrap; gap:.5rem; }
.hint-item{
  padding:.3rem .5rem;
  border:1px solid #ddd;
  border-radius:.5rem;
  cursor:pointer;
}
.hint-item:hover{ background:#f6f6f6; }

/* =========================
   TURN / DISABLED (FIXED)
   ========================= */

/* Disabled inputs should not paint grey over cell backgrounds */
.board input:disabled{
  background:transparent !important;
  cursor:not-allowed;
  opacity:1 !important;
  filter:none !important;
}

/* Not my turn: disable interaction WITHOUT washing out colors */
.board.not-my-turn{
  pointer-events:none;
  opacity:1 !important;
  filter:none !important;
}
.board.not-my-turn input{ pointer-events:none; }

/* Optional subtle overlay instead of grayscale/opacity */
/*
.board{ position:relative; }
.board.not-my-turn::after{
  content:"";
  position:absolute;
  inset:0;
  background:rgba(255,255,255,0.25);
  pointer-events:none;
}
*/

/* =========================
   FREQUENCY TEXT COLORS (single source of truth)
   JS adds: freq-top500, freq-top5000 on the INPUT
   ========================= */

.board .cell input.freq-top500,
.board .cell input.freq-top500:disabled,
.board.not-my-turn .cell input.freq-top500{
  color:#ff0000 !important;
  font-weight:800;
}

.board .cell input.freq-top5000,
.board .cell input.freq-top5000:disabled,
.board.not-my-turn .cell input.freq-top5000{
  color:purple !important;
  font-weight:800;
}

/* Optional: improve readability on dark-green anagram word cells */
.board .cell.cell-anag-word input.freq-top500,
.board .cell.cell-anag-word input.freq-top500:disabled{
  color:#E9411F !important;    /* light red */
}
.board .cell.cell-anag-word input.freq-top5000,
.board .cell.cell-anag-word input.freq-top5000:disabled{
  color:#e9d5ff !important;    /* light lavender */
}

/* =========================================================
   FINAL OVERRIDE: ANAGRAM + SOUND => ORANGE
   (put this at the VERY END of styles.css)
   ========================================================= */

/* If anagram (any of your anag classes) AND any sound-bonus class -> orange */
.board .cell.cell-anag.cell-bonus-partial,
.board .cell.cell-anag.cell-bonus-full,
.board .cell.cell-anag.cell-bonus-combo,

.board .cell.cell-anag-word.cell-bonus-partial,
.board .cell.cell-anag-word.cell-bonus-full,
.board .cell.cell-anag-word.cell-bonus-combo,

.board .cell.cell-anag-col.cell-bonus-partial,
.board .cell.cell-anag-col.cell-bonus-full,
.board .cell.cell-anag-col.cell-bonus-combo{
  background: #F6C71A !important;  /* orange */
  background-image: none !important;
  color: #fff7ed !important;
}

/* Keep text readable */
.board .cell.cell-anag.cell-bonus-partial input,
.board .cell.cell-anag.cell-bonus-full input,
.board .cell.cell-anag.cell-bonus-combo input,
.board .cell.cell-anag-word.cell-bonus-partial input,
.board .cell.cell-anag-word.cell-bonus-full input,
.board .cell.cell-anag-word.cell-bonus-combo input,
.board .cell.cell-anag-col.cell-bonus-partial input,
.board .cell.cell-anag-col.cell-bonus-full input,


.
.board .cell.cell-anag-col.cell-bonus-combo input{
  color: #FA7000 !important;
  -webkit-text-fill-color: #FA7000 !important;
}

.board .cell.cell-anag.cell-bonus-partial .ipa,
.board .cell.cell-anag.cell-bonus-full .ipa,
.board .cell.cell-anag.cell-bonus-combo .ipa,
.board .cell.cell-anag-word.cell-bonus-partial .ipa,
.board .cell.cell-anag-word.cell-bonus-full .ipa,
.board .cell.cell-anag-word.cell-bonus-combo .ipa,
.board .cell.cell-anag-col.cell-bonus-partial .ipa,
.board .cell.cell-anag-col.cell-bonus-full .ipa,
.board .cell.cell-anag-col.cell-bonus-combo .ipa{
  color: #fff7ed !important;
}

.board .cell .word.freq-top500,
.board .cell.cell-anag .word.freq-top500,
.board .cell.cell-bonus-combo .word.freq-top500 {
  color:#ff0000 !important;
  font-weight:800 !important;
}

.board .cell .word.freq-top5000,
.board .cell.cell-anag .word.freq-top5000,
.board .cell.cell-bonus-combo .word.freq-top5000 {
  color:purple !important;
  font-weight:800 !important;
}

/* ===== FINAL FINAL: let freq colors override orange forced white ===== */
.board .cell.cell-anag.cell-bonus-partial input.freq-top500,
.board .cell.cell-anag.cell-bonus-full input.freq-top500,
.board .cell.cell-anag.cell-bonus-combo input.freq-top500,
.board .cell.cell-anag-word.cell-bonus-partial input.freq-top500,
.board .cell.cell-anag-word.cell-bonus-full input.freq-top500,
.board .cell.cell-anag-word.cell-bonus-combo input.freq-top500,
.board .cell.cell-anag-col.cell-bonus-partial input.freq-top500,
.board .cell.cell-anag-col.cell-bonus-full input.freq-top500,
.board .cell.cell-anag-col.cell-bonus-combo input.freq-top500{
  color:#ff0000 !important;
  -webkit-text-fill-color:#ff0000 !important;
}

.board .cell.cell-anag.cell-bonus-partial input.freq-top5000,
.board .cell.cell-anag.cell-bonus-full input.freq-top5000,
.board .cell.cell-anag.cell-bonus-combo input.freq-top5000,
.board .cell.cell-anag-word.cell-bonus-partial input.freq-top5000,
.board .cell.cell-anag-word.cell-bonus-full input.freq-top5000,
.board .cell.cell-anag-word.cell-bonus-combo input.freq-top5000,
.board .cell.cell-anag-col.cell-bonus-partial input.freq-top5000,
.board .cell.cell-anag-col.cell-bonus-full input.freq-top5000,
.board .cell.cell-anag-col.cell-bonus-combo input.freq-top5000{
  color:purple !important;
  -webkit-text-fill-color:purple !important;
}


.daily-challenge-box{
  background:#fff;
  border:1px solid #dbe3f0;
  border-radius:16px;
  padding:16px;
  box-shadow:0 8px 24px rgba(0,0,0,.06);
}

.daily-challenge-kicker{
  font-size:.78rem;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:#4f46e5;
  margin-bottom:12px;
}

.daily-challenge-label{
  font-size:.82rem;
  color:#64748b;
  margin-bottom:6px;
}

.daily-challenge-word{
  display:block;
  width:100%;
  border:0;
  background:#eef2ff;
  color:#1e1b4b;
  font-size:1.8rem;
  font-weight:900;
  letter-spacing:.04em;
  text-align:left;
  padding:14px 16px;
  border-radius:14px;
  cursor:pointer;
  margin-bottom:14px;
}

.daily-challenge-stats{
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
  margin-bottom:14px;
}

.daily-stat{
  background:#f8fafc;
  border:1px solid #e2e8f0;
  border-radius:12px;
  padding:12px 14px;
}

.daily-stat-label{
  display:block;
  font-size:.8rem;
  color:#64748b;
  margin-bottom:4px;
}

.daily-submit-btn{
  width:100%;
  border:0;
  border-radius:12px;
  padding:12px 14px;
  font-weight:800;
  background:#4f46e5;
  color:#fff;
  cursor:pointer;
}

.board-section{
  min-width:0;
}



.cell.filled{
  background:#ffd966;
}

/* =========================
   Hint / Help modal contrast fix
   ========================= */

.modal,
.hint-modal,
.help-modal {
  background: #ffffff;
  color: #1f2937;
  border-radius: 10px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
}

/* Dark modal headers were causing poor contrast */
.modal-header,
.hint-modal-header,
.help-modal-header {
  background: #0f766e;
  color: #ffffff;
  border-radius: 10px 10px 0 0;
}

/* Title text */
.modal-header h2,
.modal-header h3,
.hint-modal-header h2,
.hint-modal-header h3,
.help-modal-header h2,
.help-modal-header h3,
#hintTitle,
#helpTitle {
  color: #ffffff;
  opacity: 1;
}

/* Close button */
.modal-close,
.hint-close,
.help-close,
.close,
#hintClose,
#helpClose {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  opacity: 1;
}

.modal-close:hover,
.hint-close:hover,
.help-close:hover,
.close:hover,
#hintClose:hover,
#helpClose:hover {
  background: #f1f5f9;
  color: #000000;
}

/* Body text inside hint/help boxes */
.modal-body,
.hint-modal-body,
.help-modal-body,
#hintBox,
#helpBox,
#hintPanel,
#helpPanel {
  background: #ffffff;
  color: #1f2937;
}

/* Hint controls row */
.hint-controls,
.help-controls {
  background: #ffffff;
  color: #1f2937;
}

/* Suggestion labels and info line */
.hint-info,
.hint-status,
.hint-page-info,
.suggestions-title {
  color: #475569;
}

/* Hint word buttons */
.hint-suggestion,
.suggestion-chip,
.hint-chip {
  background: #f8fafc;
  color: #111827;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
}

.hint-suggestion:hover,
.suggestion-chip:hover,
.hint-chip:hover {
  background: #e0f2fe;
  border-color: #38bdf8;
}

/* Main hint navigation buttons */
.hint-nav button,
.hint-actions button,
#hintShortLong,
#hintPrev,
#hintNext {
  background: #0f766e;
  color: #ffffff;
  border: none;
  border-radius: 6px;
}

.hint-nav button:hover,
.hint-actions button:hover,
#hintShortLong:hover,
#hintPrev:hover,
#hintNext:hover {
  background: #115e59;
}
