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

body {
  background: #f0ece3;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 20px;
  font-family: 'Space Grotesk', sans-serif;
  color: #1a1a20;
}

.app {
  background: #f0ece3;
  width: 100%;
  max-width: 420px;
  padding: 22px 20px 26px;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ── */
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

.game-title {
  font-family: 'Space Mono', monospace;
  font-size: 14px; font-weight: 700;
  color: #1a1a20; letter-spacing: 0.08em; text-transform: uppercase;
}

.header-right { display: flex; gap: 8px; }

.link-btn {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px; font-weight: 500;
  padding: 5px 10px; border-radius: 6px; border: 1.5px solid #d8d4cc;
  background: transparent; color: #8a8680; cursor: pointer; transition: all 0.15s;
}
.link-btn:hover { border-color: #a8a49c; color: #1a1a20; }

/* ── Mode toggle ── */
.mode-row { display: flex; gap: 4px; margin-bottom: 10px; }
.mode-btn {
  flex: 1; font-family: 'Space Grotesk', sans-serif;
  font-size: 13px; font-weight: 500;
  padding: 8px 0; border-radius: 8px; border: 1.5px solid #d8d4cc;
  background: transparent; color: #8a8680; cursor: pointer; transition: all 0.15s;
}
.mode-btn.active { background: #1a1a20; color: #fff; border-color: #1a1a20; }

/* ── Meta row ── */
.meta-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; flex-wrap: wrap; }
.meta-left { display: flex; align-items: center; gap: 8px; }
.meta-right { display: flex; align-items: center; gap: 10px; }
.meta-text { font-family: 'Space Mono', monospace; font-size: 11px; color: #6a6660; }
.timer { font-family: 'Space Mono', monospace; font-size: 13px; font-weight: 700; color: #1a1a20; min-width: 56px; text-align: right; }

.diff-wrap { display: flex; background: #e0dbd0; border-radius: 8px; padding: 3px; gap: 2px; }
.diff-btn {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px; font-weight: 500;
  padding: 4px 10px; border-radius: 6px; border: none;
  background: transparent; color: #8a8680; cursor: pointer; transition: all 0.15s;
}
.diff-btn[data-diff="easy"].active   { background: #4ecb8d; color: #fff; }
.diff-btn[data-diff="medium"].active { background: #f0a830; color: #fff; }
.diff-btn[data-diff="hard"].active   { background: #e05c6a; color: #fff; }

.daily-chip {
  font-family: 'Space Mono', monospace;
  font-size: 11px; padding: 5px 10px; border-radius: 6px;
  background: #e0dbd0; color: #6a6660; letter-spacing: 0.04em;
}

/* ── Attempts ── */
.attempts-row { display: flex; gap: 5px; align-items: center; justify-content: flex-end; margin-bottom: 14px; min-height: 9px; }
.attempt-pip {
  width: 9px; height: 9px; border-radius: 50%;
  background: #d8d4cc; border: 1.5px solid #c8c4bc; transition: all 0.2s;
}
.attempt-pip.fail { background: #e05c6a; border-color: #c0392b; }
.attempt-pip.win  { background: #4ecb8d; border-color: #2eaa6d; }

/* ── Section labels ── */
.section-label {
  font-family: 'Space Mono', monospace;
  font-size: 9px; letter-spacing: 0.15em;
  color: #a8a49c; text-transform: uppercase;
  margin-bottom: 10px; align-self: flex-start;
}

/* ── Lights ── */
.lights-section { display: flex; flex-direction: column; align-items: center; padding: 0 0 4px; }
.lights-grid { display: grid; grid-template-columns: repeat(4, 72px); gap: 8px; }

.light-cell {
  width: 72px; height: 72px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; position: relative; cursor: default; transition: all 0.18s;
}
.light-cell.target-off { background: #e8e4dc; border: 2px solid #d0ccc4; }
.light-cell.target-on  { background: #d6f5e7; border: 2px solid #4ecb8d; }
.light-cell.target-off.is-on { background: #fde8ea; border: 2px solid #e05c6a; }
.light-cell.target-on.is-on  { background: #b8f0d4; border: 2px solid #2eaa6d; }
.light-cell.highlighted { border-color: #9b8fe8 !important; background: #f0eeff !important; }

.bulb-wrap {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; transition: all 0.18s;
}
.light-cell.target-off .bulb-wrap { background: #ccc8c0; border: 2px solid #b8b4ac; }
.light-cell.target-on  .bulb-wrap { background: #4ecb8d; border: 2px solid #2eaa6d; }
.light-cell.target-off.is-on .bulb-wrap { background: #e05c6a; border: 2px solid #c0392b; }
.light-cell.target-on.is-on  .bulb-wrap { background: #2eaa6d; border: 2px solid #1d7a4e; }
.light-cell.highlighted .bulb-wrap { background: #9b8fe8 !important; border-color: #7b6fe0 !important; }

.bulb-inner { width: 10px; height: 10px; border-radius: 50%; transition: all 0.18s; }
.light-cell.target-off .bulb-inner { background: #a8a49c; }
.light-cell.target-on  .bulb-inner { background: #fff; }
.light-cell.target-off.is-on .bulb-inner { background: #fff; }
.light-cell.target-on.is-on  .bulb-inner { background: #e8fff4; }
.light-cell.highlighted .bulb-inner { background: #fff !important; }

.status-tick { position: absolute; top: 5px; right: 6px; font-size: 11px; font-weight: 700; line-height: 1; }
.light-cell.target-off .status-tick { color: #c8c4bc; }
.light-cell.target-on  .status-tick { color: #4ecb8d; }
.light-cell.target-off.is-on .status-tick { color: #e05c6a; }
.light-cell.target-on.is-on  .status-tick { color: #1d7a4e; }

.light-id { font-family: 'Space Mono', monospace; font-size: 9px; letter-spacing: 0.05em; }
.light-cell.target-off .light-id { color: #a8a49c; }
.light-cell.target-on  .light-id { color: #2eaa6d; }
.light-cell.target-off.is-on .light-id { color: #c0392b; }
.light-cell.target-on.is-on  .light-id { color: #1d7a4e; }
.light-cell.highlighted .light-id { color: #7b6fe0 !important; }

/* ── Info bar ── */
.info-bar { text-align: center; min-height: 22px; margin: 12px 0 14px; }
.info-text { font-size: 12px; color: #a8a49c; font-family: 'Space Mono', monospace; letter-spacing: 0.02em; }
.info-text.correct  { color: #2eaa6d; font-weight: 700; }
.info-text.wrong    { color: #c0392b; font-weight: 700; }
.info-text.hint     { color: #7b6fe0; }
.info-text.progress { color: #1a1a20; }

.divider { height: 1px; background: #d8d4cc; margin: 0 -20px 18px; }

/* ── Switches ── */
.switches-section { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.switches-grid { display: grid; grid-template-columns: repeat(4, 72px); gap: 8px; }

.sw-cell {
  width: 72px; height: 72px; border-radius: 12px;
  background: #fff; border: 2px solid #d8d4cc;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; cursor: pointer; transition: all 0.15s; user-select: none;
  position: relative;
}
.sw-cell:hover    { border-color: #a8a49c; background: #faf8f4; }
.sw-cell.selected  { background: #f3f1fd; border-color: #7b6fe0; }
.sw-cell.committed { background: #f8f7fe; border-color: #c4bef0; opacity: 0.65; }
.sw-cell.hinted::after {
  content: ""; position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px; border-radius: 50%; background: #7b6fe0;
}

.sw-track {
  width: 32px; height: 16px; border-radius: 8px;
  background: #ede9e2; border: 1.5px solid #d8d4cc;
  position: relative; transition: all 0.15s;
}
.sw-cell.selected  .sw-track { background: #d4cff7; border-color: #9b8fe8; }
.sw-cell.committed .sw-track { background: #e8e5fc; border-color: #c4bef0; }

.sw-knob {
  position: absolute; top: 2px; left: 2px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #c0bab2; transition: all 0.15s;
}
.sw-cell.selected  .sw-knob { left: 18px; background: #7b6fe0; }
.sw-cell.committed .sw-knob { left: 18px; background: #a09ae0; }

.sw-id { font-family: 'Space Mono', monospace; font-size: 9px; color: #b8b4ac; letter-spacing: 0.06em; }
.sw-cell.selected  .sw-id { color: #7b6fe0; font-weight: 700; }
.sw-cell.committed .sw-id { color: #a09ae0; }

/* ── Actions ── */
.action-row { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.action-row.secondary { margin-top: -4px; }

.btn-commit {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px; font-weight: 600;
  padding: 11px 32px; border-radius: 10px; border: none;
  background: #7b6fe0; color: #fff; cursor: pointer; transition: all 0.15s;
}
.btn-commit:hover    { background: #6259c4; }
.btn-commit:disabled { opacity: 0.3; cursor: default; }

.btn-ghost {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px; font-weight: 500;
  padding: 11px 18px; border-radius: 10px;
  border: 2px solid #d8d4cc; background: transparent;
  color: #8a8680; cursor: pointer; transition: all 0.15s;
}
.btn-ghost:hover { border-color: #a8a49c; color: #1a1a20; }

.btn-ghost-small {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px; font-weight: 500;
  padding: 6px 12px; border-radius: 8px;
  border: 1.5px solid #d8d4cc; background: transparent;
  color: #8a8680; cursor: pointer; transition: all 0.15s;
}
.btn-ghost-small:hover:not(:disabled) { border-color: #a8a49c; color: #1a1a20; }
.btn-ghost-small:disabled { opacity: 0.4; cursor: default; }

/* ── Legend ── */
.legend-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #8a8680; }
.legend-swatch { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; }

/* ── Modals ── */
.modal {
  position: fixed; inset: 0;
  background: rgba(26, 26, 32, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.modal-card {
  background: #fff; border-radius: 16px; padding: 24px;
  width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}
.modal-card-wide { max-width: 460px; }
.modal-title { font-size: 18px; font-weight: 600; color: #1a1a20; }
.modal-subtitle { font-size: 13px; color: #6a6660; }
.modal-body { font-size: 13px; color: #4a4640; line-height: 1.5; display: flex; flex-direction: column; gap: 8px; }
.modal-bucket { font-family: 'Space Mono', monospace; font-size: 13px; color: #7b6fe0; font-weight: 700; }
.modal-input {
  font-family: 'Space Grotesk', sans-serif; font-size: 14px;
  padding: 10px 12px; border-radius: 8px; border: 1.5px solid #d8d4cc;
  background: #faf8f4; color: #1a1a20;
}
.modal-input:focus { outline: none; border-color: #7b6fe0; background: #fff; }
.modal-error { font-size: 12px; color: #c0392b; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

/* ── Groups ── */
.group-section { display: flex; flex-direction: column; gap: 6px; }
.group-section-label {
  font-family: 'Space Mono', monospace;
  font-size: 9px; letter-spacing: 0.15em;
  color: #a8a49c; text-transform: uppercase;
}
.group-form { display: flex; gap: 8px; align-items: center; }
.group-form .modal-input { flex: 1; }

.group-list { display: flex; flex-direction: column; gap: 6px; }
.group-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: #faf8f4;
  border: 1.5px solid #ede9e2; border-radius: 10px; gap: 8px;
}
.group-row-info { display: flex; flex-direction: column; }
.group-row-name { font-size: 13px; font-weight: 600; color: #1a1a20; }
.group-row-code { font-family: 'Space Mono', monospace; font-size: 11px; color: #8a8680; letter-spacing: 0.08em; }
.group-row button {
  font-family: 'Space Grotesk', sans-serif; font-size: 11px; font-weight: 500;
  padding: 5px 10px; border-radius: 6px; border: 1.5px solid #d8d4cc;
  background: transparent; color: #6a6660; cursor: pointer;
}
.group-row button:hover { border-color: #7b6fe0; color: #7b6fe0; }

/* ── Leaderboard rows ── */
.lb-rows { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; }
.lb-row {
  display: grid; grid-template-columns: 36px 1fr auto;
  gap: 10px; padding: 8px 12px; align-items: center;
  background: #faf8f4; border-radius: 8px;
}
.lb-row.me { background: #f3f1fd; border: 1.5px solid #c4bef0; }
.lb-rank { font-family: 'Space Mono', monospace; font-size: 12px; font-weight: 700; color: #6a6660; }
.lb-name { font-size: 13px; color: #1a1a20; }
.lb-time { font-family: 'Space Mono', monospace; font-size: 12px; color: #1a1a20; }
.lb-time.empty { color: #a8a49c; font-style: italic; }

.hidden { display: none !important; }
