*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #1b3358;
  background-image:
    repeating-linear-gradient(
      135deg,
      rgba(255,255,255,0.025) 0px,
      rgba(255,255,255,0.025) 1px,
      transparent 1px,
      transparent 18px
    );
  color: #1a202c;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  flex: 1;
  overflow: hidden;
  padding: 8px;
}

.panel {
  background: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
  transition: opacity 0.15s;
}

/* ---- Panel active / inactive ---- */

.panel.inactive .panel-form,
.panel.inactive .results {
  opacity: 0.25;
  pointer-events: none;
}

.panel.inactive .panel-header {
  opacity: 0.55;
  cursor: pointer;
  filter: grayscale(0.3);
}

.panel.active .panel-header { cursor: default; }
.panel-header { cursor: pointer; }

/* ---- Panel headers ---- */

.panel-header {
  padding: 9px 12px;
  font-weight: bold;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  border-radius: 4px 4px 0 0;
}

.panel-bee .panel-header      { background: #f5c518; color: #2d2200; }
.panel-scrabble .panel-header { background: #3b82f6; color: #ffffff; }
.panel-wordle .panel-header   { background: #6aaa64; color: #ffffff; }

.activate-hint {
  font-size: 9px;
  font-weight: normal;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
}

.panel.active .activate-hint { display: none; }

/* ---- Panel form areas ---- */

.panel-form {
  padding: 10px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.form-hint {
  font-size: 12px;
  color: #4a5568;
  flex: 1;
}

button {
  background: #edf2f7;
  border: 1px solid #c0cad6;
  color: #2d3748;
  font-family: inherit;
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 3px;
  white-space: nowrap;
}

button:hover { background: #e2e8f0; }
button:disabled { opacity: 0.35; cursor: not-allowed; }

.panel-bee .btn-submit        { background: #f5c518; border-color: #d4a800; color: #2d2200; }
.panel-bee .btn-submit:hover  { background: #e6b800; }
.panel-scrabble .btn-submit       { background: #3b82f6; border-color: #2563eb; color: #fff; }
.panel-scrabble .btn-submit:hover { background: #2563eb; }
.panel-wordle .btn-submit       { background: #6aaa64; border-color: #4f8b4a; color: #fff; }
.panel-wordle .btn-submit:hover { background: #4f8b4a; }

/* ---- Letter boxes (shared) ---- */

.letter-box {
  width: 34px;
  height: 34px;
  text-align: center;
  font-size: 15px;
  font-weight: bold;
  font-family: inherit;
  border: 2px solid #c0cad6;
  background: #ffffff;
  color: #1a202c;
  border-radius: 3px;
  outline: none;
  padding: 0;
  text-transform: uppercase;
  caret-color: transparent;
}

.letter-box:focus:not(:disabled) { border-color: #4a5568; background: #f0f6ff; }
.letter-box:disabled { background: #f7f8fa; color: #c0cad6; cursor: default; }

/* ---- Spelling Bee layout ---- */

.bee-letter-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 0;
}

.bee-outer-group { display: flex; gap: 4px; }

.bee-center {
  border-color: #d4a800;
  background: #fffbea;
  color: #2d2200;
  box-shadow: 0 0 0 2px #f5c51840;
}

.bee-center:focus:not(:disabled) {
  border-color: #d4a800;
  background: #fff8d0;
  box-shadow: 0 0 0 3px #f5c51850;
}

/* ---- Scrabble layout ---- */

.scrabble-tray-row,
.scrabble-anchor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.tray-label {
  color: #718096;
  font-size: 11px;
  min-width: 44px;
  flex-shrink: 0;
}

.tray-boxes { display: flex; gap: 4px; }

.anchor-input {
  background: #ffffff;
  border: 2px solid #c0cad6;
  color: #1a202c;
  font-family: inherit;
  font-size: 13px;
  padding: 0 8px;
  height: 34px;
  flex: 1;
  outline: none;
  border-radius: 3px;
}

.anchor-input:focus { border-color: #4a5568; background: #f0f6ff; }

/* ---- Wordle grid ---- */

.wordle-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.wordle-row { display: flex; gap: 4px; }

/* Wordle box color states — classic Wordle palette */
.wordle-box[data-state="gray"]   { background: #d3d6da; border-color: #a8adb4; color: #1a202c; }
.wordle-box[data-state="yellow"] { background: #c9b458; border-color: #b09a3c; color: #fff; }
.wordle-box[data-state="green"]  { background: #6aaa64; border-color: #4f8b4a; color: #fff; }

.wordle-box:not(:disabled) { cursor: text; }
.wordle-box[data-state]:not([data-state=""]):not(:disabled) { cursor: pointer; }

/* ---- Results area ---- */

.results {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  background: #ffffff;
  scrollbar-width: thin;
  scrollbar-color: #c0cad6 #ffffff;
}

.results::-webkit-scrollbar { width: 5px; }
.results::-webkit-scrollbar-track { background: #ffffff; }
.results::-webkit-scrollbar-thumb { background: #c0cad6; border-radius: 2px; }

/* ---- Spelling Bee results ---- */

.bee-stats         { color: #96760a; margin-bottom: 8px; font-size: 12px; font-weight: bold; }
.bee-section-label {
  color: #9aa5b4; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.08em; margin-top: 10px; margin-bottom: 4px;
}
.bee-lengths       { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px,1fr)); gap: 2px; }
.bee-length-row    { display: flex; gap: 4px; color: #2d3748; font-size: 12px; }
.bee-length-num    { color: #718096; min-width: 20px; }
.bee-length-count  { color: #96760a; min-width: 24px; font-weight: bold; }
.bee-pangram       { color: #96760a; font-size: 12px; }
.bee-by-letter     { display: flex; flex-wrap: wrap; gap: 6px; }
.bee-letter-item   { font-size: 12px; color: #2d3748; }
.bee-letter-key    { color: #96760a; font-weight: bold; }
.bee-two-letter    { display: flex; flex-wrap: wrap; gap: 4px; }
.bee-pair          { font-size: 11px; color: #4a5568; background: #f0f4f8; padding: 1px 5px; border-radius: 2px; }
.bee-pair-key      { color: #96760a; font-weight: bold; }
.bee-special-item  { font-size: 12px; color: #2d3748; }
.bee-special-key   { color: #718096; }

/* ---- Scrabble results ---- */

.scrabble-word {
  display: flex; justify-content: space-between;
  padding: 2px 0; border-bottom: 1px solid #f0f4f8; font-size: 12px; color: #2d3748;
}
.scrabble-word:last-child { border-bottom: none; }
.scrabble-len { color: #9aa5b4; }

/* ---- Wordle results ---- */

.wordle-word { padding: 1px 0; font-size: 13px; letter-spacing: 0.04em; color: #2d3748; }
.wordle-word.used { color: #b0bbc8; }
.wordle-word.nyt  { color: #4f8b4a; font-weight: bold; }
.wordle-debug {
  color: #9aa5b4; font-size: 11px; margin-bottom: 8px;
  border-bottom: 1px solid #e2e8f0; padding-bottom: 6px;
}

/* ---- Shared ---- */

.error-msg { color: #e53e3e; font-size: 12px; }
.empty-msg { color: #9aa5b4; font-size: 12px; font-style: italic; }

/* ---- Word Lists bar ---- */

#wordlists-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 16px;
  background: #132844;
  border-bottom: 1px solid #0d1e33;
  flex-shrink: 0;
}

.wl-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.wl-bar-label {
  color: #4a7ab5;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-right: 4px;
}

.wl-btn {
  background: #1e3a6e;
  border: 1px solid #2a4f8a;
  color: #7eb0e8;
  font-family: inherit;
  font-size: 11px;
  padding: 3px 11px;
  cursor: pointer;
  border-radius: 3px;
}

.wl-btn:hover { background: #2a4f8a; color: #b8d4f5; }

/* ---- Word list modal ---- */

.wl-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.wl-overlay[hidden] { display: none; }

.wl-dialog {
  background: #ffffff; border: 1px solid #c0cad6; border-radius: 6px;
  width: 540px; max-width: 95vw; height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

.wl-dialog-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: #f0f4f8;
  border-bottom: 1px solid #e2e8f0; flex-shrink: 0;
}

.wl-title-text { font-size: 12px; font-weight: bold; color: #1a202c; text-transform: uppercase; letter-spacing: 0.08em; }
.wl-count-text { font-size: 11px; color: #718096; flex: 1; }
.wl-close-btn  { background: none; border: none; color: #9aa5b4; font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; }
.wl-close-btn:hover { color: #2d3748; background: none; }

.wl-search-row { padding: 8px 14px; flex-shrink: 0; border-bottom: 1px solid #e2e8f0; }
.wl-search-row input {
  width: 100%; background: #f8fafc; border: 1px solid #c0cad6;
  color: #1a202c; font-family: inherit; font-size: 13px;
  padding: 5px 8px; outline: none; border-radius: 3px;
}
.wl-search-row input:focus { border-color: #4a7ab5; background: #f0f6ff; }

.wl-list {
  flex: 1; overflow-y: auto; padding: 8px 14px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px 4px; align-content: start;
  scrollbar-width: thin; scrollbar-color: #c0cad6 #ffffff;
}
.wl-list::-webkit-scrollbar { width: 5px; }
.wl-list::-webkit-scrollbar-track { background: #ffffff; }
.wl-list::-webkit-scrollbar-thumb { background: #c0cad6; border-radius: 2px; }

.wl-word { font-size: 12px; color: #2d3748; padding: 1px 2px; }

.help-btn { margin-left: auto; background: #1e3a6e; border-color: #4a7ab5; color: #a0c4f0; font-weight: bold; }
.help-btn:hover { background: #2a5298; color: #d0e8ff; }

.help-dialog { height: auto; max-height: 85vh; }

.help-body {
  overflow-y: auto; padding: 16px 20px;
  scrollbar-width: thin; scrollbar-color: #c0cad6 #ffffff;
}
.help-body::-webkit-scrollbar { width: 5px; }
.help-body::-webkit-scrollbar-thumb { background: #c0cad6; border-radius: 2px; }

.help-section { margin-bottom: 20px; }
.help-heading {
  font-size: 11px; font-weight: bold; text-transform: uppercase;
  letter-spacing: 0.1em; color: #1b3358; border-bottom: 1px solid #e2e8f0;
  padding-bottom: 4px; margin-bottom: 8px;
}
.help-section p { font-size: 12px; color: #2d3748; margin-bottom: 6px; line-height: 1.5; }

.help-table { border-collapse: collapse; margin-bottom: 8px; font-size: 12px; }
.help-table td { padding: 2px 10px 2px 0; color: #2d3748; vertical-align: top; }
.help-table td:first-child { font-family: 'Courier New', monospace; color: #1b3358; font-weight: bold; white-space: pre; }

.help-swatch { border-radius: 3px; padding: 1px 8px; font-weight: bold; font-size: 11px; }
.swatch-gray   { background: #d3d6da; color: #1a202c; }
.swatch-yellow { background: #c9b458; color: #fff; }
.swatch-green  { background: #6aaa64; color: #fff; }

.wl-cap-notice {
  grid-column: 1 / -1;
  font-size: 11px; color: #9aa5b4; font-style: italic; padding: 6px 0;
}

.pat-list-single {
  grid-template-columns: repeat(6, 1fr);
}
