/* crossplay-helper — dark, handsome, mobile-first */

:root {
  --bg:        #0e1116;
  --bg-elev:   #161b22;
  --bg-elev-2: #1c232c;
  --border:    #2a323d;
  --text:      #e6edf3;
  --text-dim:  #9aa7b4;
  --accent:    #4076c6;   /* Crossplay tile blue */
  --accent-2:  #5b8de0;
  --good:      #3fb950;
  --warn:      #d29922;
  --bad:       #f85149;

  /* premium square colors (text/labels) */
  --p-3l: #4a9d5b;  /* triple letter — green  */
  --p-2l: #c2a14d;  /* double letter — tan    */
  --p-3w: #a44fb0;  /* triple word   — purple */
  --p-2w: #6f8fd6;  /* double word   — blue   */

  --cell-empty: #232a33;
  --tile-bg:    #4076c6;
  --tile-text:  #ffffff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 64px;
  min-height: 100vh;
}

header.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}
header.masthead h1 {
  font-size: 1.25rem;
  letter-spacing: 0.3px;
  margin: 0;
}
header.masthead h1 .mark { color: var(--accent-2); }
.help-btn {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font: inherit; font-weight: 700; font-size: 1rem;
  line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.help-btn:hover { border-color: var(--accent); color: var(--text); }
.help-btn:active { transform: translateY(1px); }

/* ---- cards / sections ---- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin: 0 0 12px;
}

/* ---- buttons ---- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---- upload dropzone ---- */
.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone.drag { border-color: var(--accent); background: rgba(64,118,198,.08); }
.dropzone strong { color: var(--text); }
.hidden { display: none !important; }

/* ---- status line ---- */
.status {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 10px 0 0;
}
.status:empty { margin: 0; }
.status.ok  { color: var(--good); }
.status.err { color: var(--bad); }

/* ---- board grid (correction UI) ---- */
.board-wrap { overflow-x: auto; }
.board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 2px;
  width: 100%;
  aspect-ratio: 1 / 1;
  user-select: none;
}
.cell {
  position: relative;
  background: var(--cell-empty);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: clamp(8px, 2.4vw, 15px);
  color: var(--text);
  cursor: pointer;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}
.cell.tile { background: var(--tile-bg); color: var(--tile-text); }
.cell.premium { font-size: clamp(6px, 1.8vw, 11px); font-weight: 800; }
.cell.p-3l { color: var(--p-3l); } .cell.p-2l { color: var(--p-2l); }
.cell.p-3w { color: var(--p-3w); } .cell.p-2w { color: var(--p-2w); }
.cell .val {
  position: absolute;
  right: 2px; bottom: 1px;
  font-size: 0.55em;
  font-weight: 600;
  opacity: .9;
}
.cell.lowconf::after {
  content: "";
  position: absolute; inset: 0;
  border: 2px solid var(--warn);
  border-radius: 3px;
  pointer-events: none;
}
.cell.selected { outline: 2px solid var(--accent-2); outline-offset: -1px; z-index: 2; }
.cell.blank .letter { font-style: italic; opacity: .85; }

/* ---- tray ---- */
.tray {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.tray .tile {
  width: 36px; height: 36px;
  background: var(--tile-bg); color: var(--tile-text);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .95rem;
  position: relative; cursor: pointer;
}
.tray .tile .val { position: absolute; right: 2px; bottom: 0; font-size: .55rem; font-weight: 600; }
.tray .tile.empty { background: var(--bg-elev-2); border: 1px dashed var(--border); color: var(--text-dim); }
.tray .tile.lowconf { box-shadow: 0 0 0 2px var(--warn); }

/* ---- cell editor popover ---- */
.editor {
  position: fixed;
  left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: 100%; max-width: 560px;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  box-shadow: 0 -8px 30px rgba(0,0,0,.5);
  z-index: 50;
}
.editor h3 { margin: 0 0 12px; font-size: .95rem; color: var(--text-dim); }
.editor .keys { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.editor .keys button {
  padding: 10px 0; font-weight: 700; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text); cursor: pointer;
}
.editor .keys button:hover { border-color: var(--accent); }
.editor .row { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.editor label { font-size: .85rem; color: var(--text-dim); }
.editor input[type="number"] {
  width: 64px; background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 8px; font: inherit;
}

/* ---- candidate play overlay on the board ---- */
.cell.candidate { background: var(--good); color: #06210c; }
.cell.candidate .val { opacity: .8; }
.cell.candidate.blank .letter { font-style: italic; }

/* ---- segmented toggle ---- */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; margin-bottom: 10px; }
.seg-btn {
  appearance: none; border: 0; background: var(--bg-elev-2); color: var(--text-dim);
  font: inherit; font-weight: 600; font-size: .85rem; padding: 8px 14px; cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--accent); color: #fff; }

/* ---- best plays list ---- */
.plays { list-style: none; margin: 8px 0 0; padding: 0; }
.plays li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 8px; cursor: pointer; transition: border-color .12s, background .12s;
}
.plays li:hover { border-color: var(--accent); }
.plays li.selected { border-color: var(--accent-2); background: rgba(64,118,198,.10); }
.plays .rank { color: var(--text-dim); font-size: .8rem; width: 1.4em; text-align: right; }
.plays .word { font-weight: 800; letter-spacing: .5px; }
.plays .meta { color: var(--text-dim); font-size: .8rem; }
.plays .scorebox { margin-left: auto; text-align: right; line-height: 1.1; }
.plays .score { font-weight: 800; color: var(--accent-2); font-size: 1.1rem; }
.plays .score small { font-weight: 600; color: var(--text-dim); font-size: .68rem; }
.plays .eq { display: block; color: var(--text-dim); font-size: .72rem; }
.plays .blanktag { color: var(--warn); font-size: .72rem; }
.plays .risk { color: var(--bad); font-size: .72rem; }
.plays .keep { color: var(--text); }

/* ---- preview canvas (debug) ---- */
.preview { max-width: 100%; border-radius: 10px; border: 1px solid var(--border); display: block; }
.muted { color: var(--text-dim); font-size: .8rem; }

footer { text-align: center; color: var(--text-dim); font-size: .75rem; margin-top: 24px; }
footer a { color: var(--accent-2); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ---- "how it works" modal ---- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 60;
}
.modal-sheet {
  position: relative;
  width: 100%; max-width: 420px;
  max-height: 85vh; overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.modal-sheet h3 { margin: 0 0 12px; font-size: 1.05rem; }
.modal-sheet p { margin: 0 0 12px; font-size: .9rem; }
.modal-sheet em { color: var(--text); font-style: normal; font-weight: 600; }
.modal-x {
  position: absolute; top: 10px; right: 12px;
  width: 30px; height: 30px;
  border: 0; background: transparent;
  color: var(--text-dim); font-size: 1.5rem; line-height: 1;
  cursor: pointer; border-radius: 8px;
}
.modal-x:hover { color: var(--text); background: var(--bg-elev-2); }
.help-steps { margin: 0 0 12px; padding-left: 20px; font-size: .9rem; }
.help-steps li { margin-bottom: 8px; }
.help-steps strong { color: var(--accent-2); }
