@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Inter:wght@400;500;600;700&display=swap');

:root{
  --bg: #12151b;
  --panel: #1b2029;
  --panel-raised: #232a36;
  --line: #2c3340;
  --text: #eef1f6;
  --text-dim: #8d96a6;
  --accent: #f2b544;
  --accent-dim: #7a6023;
  --good: #4fc48a;
  --danger: #e0605f;
  --ghost: #1a1e27;
  --ghost-lit: #474b53;

  --font-display: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

*{ box-sizing: border-box; }

html, body{
  margin:0;
  padding:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

button, input, textarea{
  font-family: inherit;
}

/* ---------- Header ---------- */

.site-header{
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--line);
}

.wordmark{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 32px;
  letter-spacing: 0.5px;
}
.wordmark-score{ color: var(--text); }
.wordmark-space{ color: var(--accent); }

.site-sub{
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-dim);
}

/* ---------- Layout ---------- */

.layout{
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - 96px);
}

/* ---------- Left nav ---------- */

.game-nav{
  flex: 0 0 18%;
  max-width: 234px;
  min-width: 135px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line);
}

.game-nav-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Deliberately low-contrast: meant to be easy to overlook unless you
   already know it's there. Just barely lighter than the page background
   at rest; only reveals itself (dimly) on hover/focus. Narrow and
   left-justified like the game buttons above it, rather than a full-width
   button, so it doesn't look like part of that list. */
.mods-btn{
  width: 33%;
  align-self: flex-start;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ghost);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-align: left;
  cursor: pointer;
}

.mods-btn:hover,
.mods-btn:focus-visible{
  color: var(--ghost-lit);
  border-color: var(--ghost);
  outline: none;
}

.game-btn{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.game-btn-label{
  flex: 1 1 auto;
  min-width: 0;
}

/* Post count for the day currently being viewed. Right-justified via the
   flex row above; only rendered by app.js when the count is > 0. */
.game-btn-count{
  flex: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.game-btn.active .game-btn-count{
  color: var(--text);
}

.game-btn:hover{
  border-color: var(--accent-dim);
  background: var(--panel-raised);
}

.game-btn:focus-visible{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.game-btn.active{
  background: var(--panel-raised);
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* ---------- Board (right side) ---------- */

.board{
  flex: 1 1 80%;
  min-width: 0;
  padding: 24px 28px 60px;
}

.board-empty{
  color: var(--text-dim);
  font-size: 15px;
  padding: 40px 4px;
}

/* Play row */

.play-row{
  margin-bottom: 20px;
}

.play-btn{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  background: var(--accent);
  color: #1b1404;
  border: none;
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.play-btn:hover{ filter: brightness(1.08); }
.play-btn:active{ transform: translateY(1px); }
.play-btn:focus-visible{ outline: 2px solid var(--text); outline-offset: 3px; }

.play-icon{ font-size: 12px; }

/* day-tabs-row always spans the full board width and carries the divider
   line beneath it. The day-tabs element inside it is the one whose width
   app.js actually sets -- natural (shrink-to-fit) width when all 7 fit on
   one line, or 100% when they've broken into two rows. Tiles are a
   separate sibling below and are never constrained by day-tabs' width --
   they always span the full board width, in 3 or 2 columns depending on
   which day-tabs mode is active. */

.day-tabs-row{
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
}

.day-tabs{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Single-row mode: all 7 day buttons on one line, natural width, not stretched. */
.day-tabs.mode-single{
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
}

.day-tabs.mode-single .day-tab{
  flex: none;
}

/* Split mode: two full-width rows (4 then 3), each button stretched to
   share its row evenly. */
.day-tab-row{
  display: flex;
  gap: 8px;
}

.day-tab-row .day-tab{
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  white-space: normal;
  line-height: 1.3;
}

/* Off-screen measuring copy of a single-row day-tabs bar. Never visible;
   app.js reads its scrollWidth to decide which mode to render. */
.day-tabs-ruler{
  position: fixed;
  left: -9999px;
  top: -9999px;
  visibility: hidden;
  pointer-events: none;
  margin: 0;
  padding: 0;
  border: none;
}

.day-tab{
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.day-tab:hover{
  color: var(--text);
  border-color: var(--accent-dim);
}

.day-tab:focus-visible{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.day-tab.active{
  background: var(--panel-raised);
  color: var(--text);
  border-color: var(--accent);
}

.day-tab.is-today::after{
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--good);
  margin: 6px auto 0;
}

/* Tiles: always full board width. Exact column count (3 or 2) is set by
   app.js via these classes, driven by whether the day tabs fit in one row. */

.tiles{
  display: grid;
  gap: 16px;
}

.tiles.cols-3{ grid-template-columns: repeat(3, 1fr); }
.tiles.cols-2{ grid-template-columns: repeat(2, 1fr); }

@media (max-width: 620px){
  .layout{ flex-direction: column; }
  .game-nav{
    flex: none;
    max-width: none;
    width: 100%;
    flex-direction: column;
    gap: 10px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .game-nav-list{
    flex-direction: row;
    flex-wrap: wrap;
  }
  .game-btn{ width: auto; flex: 1 1 auto; }
  .board{ padding: 20px 16px 48px; }
}

.tile{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
}

.tile-enter{
  align-items: center;
  justify-content: center;
  text-align: center;
  background: transparent;
  border: 1.5px dashed var(--line);
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.4px;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.tile-enter:hover{
  border-color: var(--accent);
  color: var(--accent);
}

.tile-enter:focus-visible{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tile-enter .tile-enter-plus{
  font-size: 22px;
  display: block;
  margin-bottom: 6px;
}

.tile-score-name{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.tile-score-name-text{
  overflow-wrap: anywhere;
}

.tile-score-meta{
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tile-score-time{
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
}

.tile-score-text{
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  margin: 0;
}

.tile-edit-btn{
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1;
  padding: 5px 7px;
  cursor: pointer;
}

.tile-edit-btn:hover,
.tile-edit-btn:focus-visible{
  color: var(--danger);
  background: rgba(224, 96, 95, 0.12);
  border-color: var(--danger);
  outline: none;
}

/* A tile with an unsaved local edit staged (not yet sent to the server). */
.tile.is-pending-edit{
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.tile-pending-badge{
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

/* A tile staged for deletion (not yet sent to the server). */
.tile.is-pending-delete{
  opacity: 0.55;
}

.tile.is-pending-delete .tile-score-text,
.tile.is-pending-delete .tile-score-name-text{
  text-decoration: line-through;
}

.tile-restore-btn{
  margin-top: 10px;
  align-self: flex-start;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
}

.tile-restore-btn:hover{
  color: var(--text);
  border-color: var(--accent-dim);
}

.tiles-empty-note{
  grid-column: 1 / -1;
  color: var(--text-dim);
  font-size: 13px;
  padding: 4px 2px 0;
}

/* ---------- Modal ---------- */

.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-overlay[hidden]{
  display: none;
}

.modal{
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 26px 24px;
}

.modal-close{
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover{ color: var(--text); }

.modal h2{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  margin: 0 0 6px;
}

.modal-context{
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 20px;
}

/* Used where the context line is a short "GAME — Day" style label rather
   than a full instructional sentence, so it reads with the same weight
   as the heading above it. */
.modal-context-lead{
  font-size: 20px;
  font-weight: 700;
}

.field-label{
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  margin: 16px 0 6px;
}

.field-label:first-of-type{ margin-top: 0; }

.field-input, .field-textarea{
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}

.field-textarea{
  resize: vertical;
  min-height: 160px;
  line-height: 1.5;
}

.field-input:focus, .field-textarea:focus{
  outline: none;
  border-color: var(--accent);
}

.field-hint{
  font-size: 12px;
  color: var(--text-dim);
  margin: 8px 0 0;
}

.field-error{
  font-size: 13px;
  color: #ef6f6f;
  margin: 10px 0 0;
}

.modal-actions{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.modal-actions-split{
  justify-content: space-between;
}

.modal-actions-right{
  display: flex;
  gap: 10px;
}

.btn-secondary, .btn-primary, .btn-danger{
  padding: 10px 18px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
}

.btn-secondary{
  background: transparent;
  color: var(--text-dim);
}
.btn-secondary:hover{ color: var(--text); }

.btn-primary{
  background: var(--accent);
  color: #1b1404;
  border-color: var(--accent);
}
.btn-primary:hover{ filter: brightness(1.08); }
.btn-primary:disabled{ opacity: 0.6; cursor: not-allowed; }

.btn-danger{
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover{ background: rgba(224, 96, 95, 0.12); }

select.field-input{
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

/* ---------- Moderator bar ---------- */

.mod-bar{
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 24px;
  background: #241a0c;
  border-top: 2px solid var(--danger);
  border-bottom: 2px solid var(--danger);
  box-shadow: 0 0 8px rgba(224, 96, 95, 0.45);
}

.mod-bar[hidden]{
  display: none;
}

.mod-bar-label{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.6px;
  color: var(--accent);
  white-space: nowrap;
}

.mod-bar-status{
  flex: 1;
  min-width: 120px;
  font-size: 13px;
  color: var(--text-dim);
}

.mod-bar-actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mod-bar-btn{
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.mod-bar-btn:hover{
  color: var(--text);
  border-color: var(--accent-dim);
}

.mod-bar-btn-primary{
  background: var(--accent);
  color: #1b1404;
  border-color: var(--accent);
}
.mod-bar-btn-primary:hover{ filter: brightness(1.08); color: #1b1404; }

/* Outlined in the same bright red as the per-tile Edit button, and
   uppercase, so Exit reads as clearly distinct from Discard/Save. */
.mod-bar-btn-exit{
  border-color: var(--danger);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.mod-bar-btn-exit:hover{
  color: var(--danger);
  background: rgba(224, 96, 95, 0.12);
  border-color: var(--danger);
}

/* ---------- Toast ---------- */

.toast{
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-raised);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 60;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
}

.toast.error{
  border-color: #7a2c2c;
  color: #ffb3b3;
}
