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

:root {
  --bg: #0a0a0f;
  --sur: #12121a;
  --sur2: #1c1c28;
  --gold: #c9a961;
  --gold-dim: rgba(201,169,97,0.18);
  --text: #e8e0cc;
  --sub: #7a7468;
  --muted: #3a3830;
  --green: #4caf7d;
  --red: #e05252;
  --blue: #5a8ae8;
  --font-num: 'Oswald', sans-serif;
  --font-body: 'Noto Sans JP', sans-serif;
  --bar-h: 48px;
  --progress-h: 4px;
  --strip-h: 48px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
}

/* ── SITE BAR ── */
.site-bar {
  display: flex;
  align-items: center;
  height: var(--bar-h);
  padding: 0 16px;
  background: var(--sur);
  border-bottom: 1px solid var(--muted);
  gap: 12px;
  flex-shrink: 0;
}
.site-logo {
  font-family: var(--font-num);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--text);
  text-decoration: none;
}
.site-logo .k { color: var(--gold); }
.site-bar-label {
  font-family: var(--font-num);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  color: var(--sub);
  text-transform: uppercase;
  margin-right: auto;
}
.site-bar-right { display: flex; gap: 4px; }

.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  background: none; border: none; cursor: pointer;
  color: var(--sub);
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--sur2); color: var(--text); }

/* ── MAIN TIMER ── */
.timer-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: calc(100vh - var(--bar-h) - var(--progress-h) - var(--strip-h));
  padding: 16px;
  position: relative;
  gap: 0;
  overflow: hidden;
}

/* level row */
.level-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.level-label {
  font-family: var(--font-num);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  color: var(--sub);
}
.level-num {
  font-family: var(--font-num);
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}
.level-total {
  font-family: var(--font-num);
  font-size: 0.9rem;
  color: var(--sub);
}

/* countdown */
.countdown {
  font-family: var(--font-num);
  font-size: clamp(5rem, 18vw, 11rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 12px;
  transition: color 0.3s;
  cursor: default;
  user-select: none;
}
.countdown.warning { color: #e09050; }
.countdown.danger  { color: var(--red); }

/* blinds */
.blinds-row {
  display: flex;
  align-items: center;
  gap: clamp(12px, 3vw, 32px);
  margin-bottom: 12px;
}
.blind-block { text-align: center; }
.blind-label {
  font-family: var(--font-num);
  font-size: 0.62rem;
  letter-spacing: 0.3em;
  color: var(--sub);
  margin-bottom: 4px;
}
.blind-val {
  font-family: var(--font-num);
  font-size: clamp(1.6rem, 5vw, 3rem);
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.04em;
}
.blind-sep {
  font-family: var(--font-num);
  font-size: clamp(1.4rem, 4vw, 2.4rem);
  color: var(--muted);
  margin-top: 22px;
}
.ante-block { margin-left: clamp(8px, 2vw, 20px); padding-left: clamp(8px, 2vw, 20px); border-left: 1px solid var(--muted); }
.ante-block.hidden { display: none; }

/* next */
.next-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.next-label {
  font-family: var(--font-num);
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  color: var(--sub);
}
.next-val {
  font-family: var(--font-num);
  font-size: 0.95rem;
  color: var(--sub);
}

/* controls */
.controls {
  display: flex;
  align-items: center;
  gap: 16px;
}
.ctrl-btn {
  border: none; cursor: pointer; border-radius: 50%;
  display: grid; place-items: center;
  transition: background 0.15s, transform 0.1s;
}
.ctrl-btn:active { transform: scale(0.93); }
.ctrl-btn.primary {
  width: clamp(64px, 12vw, 88px);
  height: clamp(64px, 12vw, 88px);
  background: var(--gold);
  color: #0a0a0f;
}
.ctrl-btn.primary svg { width: 32px; height: 32px; }
.ctrl-btn.primary:hover { background: #d9b97a; }
.ctrl-btn.secondary {
  width: clamp(48px, 8vw, 64px);
  height: clamp(48px, 8vw, 64px);
  background: var(--sur2);
  color: var(--text);
}
.ctrl-btn.secondary svg { width: 24px; height: 24px; }
.ctrl-btn.secondary:hover { background: var(--muted); }

/* break badge */
.break-badge {
  position: absolute;
  top: 12px; right: 16px;
  background: var(--blue);
  color: #fff;
  font-family: var(--font-num);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  padding: 4px 12px;
  border-radius: 2px;
}

/* ── PROGRESS BAR ── */
.progress-wrap {
  height: var(--progress-h);
  background: var(--muted);
  flex-shrink: 0;
}
.progress-bar {
  height: 100%;
  background: var(--gold);
  width: 100%;
  transition: width 1s linear;
}

/* ── LEVEL STRIP ── */
.level-strip {
  height: var(--strip-h);
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--sur);
  border-top: 1px solid var(--muted);
  scrollbar-width: none;
  flex-shrink: 0;
}
.level-strip::-webkit-scrollbar { display: none; }

.strip-item {
  flex-shrink: 0;
  min-width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 12px;
  border-right: 1px solid var(--muted);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.strip-item:hover { background: var(--sur2); }
.strip-item.active { background: var(--gold-dim); }
.strip-item.active::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gold);
}
.strip-lv {
  font-family: var(--font-num);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  color: var(--sub);
}
.strip-blinds {
  font-family: var(--font-num);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.strip-item.is-break .strip-blinds {
  color: var(--blue);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
}
.strip-item.done .strip-blinds { color: var(--sub); }
.strip-item.done .strip-lv { opacity: 0.5; }

/* ── EDIT OVERLAY ── */
.edit-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: grid; place-items: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.edit-overlay[hidden] { display: none; }

.edit-panel {
  background: var(--sur);
  border: 1px solid var(--muted);
  border-radius: 8px;
  width: min(680px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--muted);
  flex-shrink: 0;
}
.edit-header h2 {
  font-family: var(--font-num);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.edit-header-actions { display: flex; align-items: center; gap: 8px; }

.text-btn {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--sub);
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s;
}
.text-btn:hover { color: var(--text); }

.edit-table-wrap {
  overflow-y: auto;
  flex: 1;
  padding: 12px 20px;
}

.edit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.edit-table th {
  font-family: var(--font-num);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  color: var(--sub);
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--muted);
}
.edit-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(58,56,48,0.5);
  vertical-align: middle;
}
.edit-table tr:last-child td { border-bottom: none; }

.edit-table td:first-child {
  font-family: var(--font-num);
  font-size: 0.72rem;
  color: var(--sub);
  width: 28px;
}

.edit-input {
  width: 100%;
  background: var(--sur2);
  border: 1px solid var(--muted);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-num);
  font-size: 0.9rem;
  padding: 5px 8px;
  text-align: right;
  transition: border-color 0.15s;
  min-width: 60px;
}
.edit-input:focus { outline: none; border-color: var(--gold); }

.edit-check {
  width: 18px; height: 18px;
  cursor: pointer;
  accent-color: var(--blue);
}

.del-btn {
  background: none; border: none; cursor: pointer;
  color: var(--sub);
  padding: 4px;
  border-radius: 4px;
  display: grid; place-items: center;
  transition: color 0.15s, background 0.15s;
}
.del-btn:hover { color: var(--red); background: rgba(224,82,82,0.1); }
.del-btn svg { width: 16px; height: 16px; }

.add-btn {
  margin: 0 20px 12px;
  background: none;
  border: 1px dashed var(--muted);
  border-radius: 4px;
  color: var(--sub);
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 8px;
  cursor: pointer;
  width: calc(100% - 40px);
  transition: color 0.15s, border-color 0.15s;
}
.add-btn:hover { color: var(--text); border-color: var(--sub); }

.edit-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--muted);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}
.btn-save {
  background: var(--gold);
  color: #0a0a0f;
  border: none;
  border-radius: 4px;
  font-family: var(--font-num);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 10px 28px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-save:hover { background: #d9b97a; }

/* ── BREAK MODAL ── */
.break-modal {
  position: absolute; inset: 0;
  background: rgba(10,10,15,0.94);
  display: grid; place-items: center;
  z-index: 10;
}
.break-modal[hidden] { display: none; }
.break-modal-inner { text-align: center; }
.break-title {
  font-family: var(--font-num);
  font-size: 1rem;
  letter-spacing: 0.4em;
  color: var(--blue);
  margin-bottom: 16px;
}
.break-countdown {
  font-family: var(--font-num);
  font-size: clamp(5rem, 20vw, 12rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.break-next {
  font-family: var(--font-num);
  font-size: 1rem;
  color: var(--sub);
  margin-top: 20px;
  letter-spacing: 0.1em;
}
.break-skip {
  margin-top: 28px;
  background: none;
  border: 1px solid var(--muted);
  border-radius: 4px;
  color: var(--sub);
  font-family: var(--font-num);
  font-size: 0.82rem;
  letter-spacing: 0.15em;
  padding: 8px 24px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.break-skip:hover { border-color: var(--sub); color: var(--text); }

/* ── FULLSCREEN ── */
:fullscreen body { overflow: hidden; }
:fullscreen .site-bar { display: none; }
:fullscreen .timer-main {
  height: calc(100vh - var(--progress-h) - var(--strip-h));
}

/* ── MOBILE ── */
@media (max-width: 480px) {
  .level-strip { --strip-h: 42px; }
  .strip-item { min-width: 70px; }
  .blind-val { font-size: 1.8rem; }
}

/* ── LANDING ── */
#landing {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.landing-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.landing-bar {
  display: flex;
  align-items: center;
  height: var(--bar-h);
  padding: 0 16px;
  background: var(--sur);
  border-bottom: 1px solid var(--muted);
  gap: 12px;
}
.landing-bar-label {
  font-family: var(--font-num);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  color: var(--sub);
  text-transform: uppercase;
}
.landing-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 32px 16px;
}
.recent-heading {
  font-family: var(--font-num);
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  color: var(--sub);
  text-transform: uppercase;
  align-self: flex-start;
  max-width: 420px;
  width: 100%;
}
.recent-list {
  list-style: none;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--sur);
  border: 1px solid var(--muted);
  border-radius: 6px;
  padding: 12px 12px 12px 16px;
}
.recent-link {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}
.recent-link:hover .recent-name { color: var(--gold); }
.recent-name {
  font-family: var(--font-num);
  font-size: 0.95rem;
  font-weight: 600;
  transition: color 0.15s;
}
.recent-date {
  font-size: 0.75rem;
  color: var(--sub);
}
.recent-del { margin-left: auto; }
.recent-empty {
  font-family: var(--font-num);
  font-size: 0.8rem;
  color: var(--sub);
}
.btn-new {
  background: var(--gold);
  color: #0a0a0f;
  border: none;
  border-radius: 6px;
  font-family: var(--font-num);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 14px 32px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-new:hover { background: #d9b97a; }

/* ── CREATE MODAL ── */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: grid; place-items: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}
.modal-bg[hidden] { display: none; }
.create-panel {
  background: var(--sur);
  border: 1px solid var(--muted);
  border-radius: 8px;
  width: min(440px, 96vw);
  overflow: hidden;
}
.create-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--muted);
}
.create-header h2 {
  font-family: var(--font-num);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.create-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px 20px;
}
.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.form-label {
  font-family: var(--font-num);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  color: var(--sub);
  width: 64px;
  flex-shrink: 0;
}
.create-note {
  font-size: 0.72rem;
  color: var(--sub);
  margin-top: 4px;
}

/* ── ANTE MODE in edit header ── */
.ante-label-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ante-label {
  font-family: var(--font-num);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--sub);
  white-space: nowrap;
}
.ante-select {
  background: var(--sur2);
  border: 1px solid var(--muted);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-num);
  font-size: 0.8rem;
  padding: 4px 8px;
  cursor: pointer;
}
.ante-select:focus { outline: none; border-color: var(--gold); }

/* ── STATS PANEL ── */
.stats-panel {
  background: var(--sur);
  border: 1px solid var(--muted);
  border-radius: 8px;
  width: min(400px, 96vw);
  overflow: hidden;
}
.stats-body {
  padding: 12px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stat-label {
  font-family: var(--font-num);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--sub);
  flex-shrink: 0;
}
.stat-input {
  width: 110px;
  text-align: right;
}
.stat-divider {
  height: 1px;
  background: var(--muted);
  margin: 4px 0;
}
.stat-counter {
  display: flex;
  align-items: center;
  gap: 12px;
}
.counter-btn {
  background: var(--sur2);
  border: 1px solid var(--muted);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-num);
  font-size: 1.1rem;
  width: 32px; height: 32px;
  cursor: pointer;
  transition: background 0.15s;
}
.counter-btn:hover { background: var(--muted); }
.counter-val {
  font-family: var(--font-num);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  min-width: 40px;
  text-align: center;
}
.stat-row.computed .stat-label { color: var(--sub); }
.stat-computed-val {
  font-family: var(--font-num);
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold);
}

/* ── QR PANEL ── */
.qr-panel {
  background: var(--sur);
  border: 1px solid var(--muted);
  border-radius: 8px;
  width: min(320px, 96vw);
  overflow: hidden;
}
.qr-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.qr-canvas {
  background: #fff;
  padding: 8px;
  border-radius: 4px;
  line-height: 0;
}
.qr-url {
  font-family: var(--font-num);
  font-size: 0.65rem;
  color: var(--sub);
  word-break: break-all;
  text-align: center;
}
