:root {
  --bg: #0b0f0d;
  --card: #141a17;
  --card2: #1c2520;
  --line: #27322c;
  --text: #eef3f0;
  --mute: #8b9891;
  --accent: #34d399;
  --accent-ink: #04130c;
  --warn: #fbbf24;
  --danger: #f87171;
  --r: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  min-height: 100dvh;
}
body.dragging { user-select: none; -webkit-user-select: none; overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 110px);
}

header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.spade { color: var(--accent); }
#sub { margin: 2px 0 0; color: var(--mute); font-size: 14px; }
#badge {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 99px; padding: 5px 10px;
}

.head-tools { display: flex; align-items: center; gap: 8px; }
#share {
  display: flex; align-items: center; gap: 7px; height: 42px; padding: 0 14px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--line); font-weight: 700; font-size: 14px;
}
#share:active { background: var(--card2); }
img.av { object-fit: cover; display: block; }
h1 { white-space: nowrap; }
.admin #share { width: 42px; padding: 0; justify-content: center; }
.admin #share span { display: none; }

/* Day tabs */
#tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  position: sticky; top: 0; z-index: 5;
  padding: 8px 0 12px; background: linear-gradient(var(--bg) 80%, transparent);
}
.tab {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: background .15s, border-color .15s, transform .1s;
}
.tab:active { transform: scale(.97); }
.tab b { font-size: 17px; font-weight: 700; }
.tab span { font-size: 12px; color: var(--mute); }
.tab i {
  font-style: normal; font-size: 12px; font-weight: 700; margin-top: 6px;
  background: var(--card2); color: var(--mute); border-radius: 99px; padding: 2px 9px;
}
.tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tab.on span { color: rgba(4, 19, 12, .7); }
.tab.on i { background: rgba(4, 19, 12, .16); color: var(--accent-ink); }

/* Lists */
section { margin-top: 14px; }
section h2 {
  display: flex; align-items: center; gap: 8px; margin: 0 4px 10px;
  font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mute);
}
section h2 .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
section.wait h2 .dot { background: var(--warn); }
section h2 em { font-style: normal; margin-left: auto; color: var(--text); }

.zone { display: flex; flex-direction: column; gap: 8px; min-height: 60px; counter-reset: n; }
.zone:empty::before {
  content: attr(data-empty);
  display: grid; place-items: center; min-height: 60px;
  border: 1.5px dashed var(--line); border-radius: var(--r); color: var(--mute); font-size: 14px;
}
.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 10px 10px 14px; min-height: 60px;
  counter-increment: n;
}
.row .num { width: 18px; text-align: center; color: var(--mute); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.row .num::before { content: counter(n); }
.av {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 14px; font-weight: 700; color: #fff;
}
.name { flex: 1; min-width: 0; font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .name { display: flex; flex-direction: column; justify-content: center; align-self: stretch; }
.row .name > * { overflow: hidden; text-overflow: ellipsis; }
.note { font-size: 13px; font-weight: 600; color: var(--warn); margin-top: 1px; }
.note.add { color: var(--mute); font-weight: 500; opacity: .7; }
.row .name[data-act], .note.line { cursor: pointer; }
.row { flex-wrap: wrap; }
.note.line { flex-basis: 100%; margin: -2px 0 2px 80px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wait .row { background: transparent; }
.wait .av { opacity: .75; }

.ic {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-size: 17px; color: var(--mute); background: var(--card2);
}
.ic:active { background: var(--line); color: var(--text); }
.ic.rm:active { color: var(--danger); }
.grip {
  width: 34px; height: 44px; flex: none; display: grid; place-items: center;
  color: var(--mute); touch-action: none; cursor: grab;
}
.row.drag {
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55); border-color: var(--accent); background: var(--card2);
  transform: scale(1.03); counter-increment: none;
}
.ph { border: 1.5px dashed var(--accent); border-radius: var(--r); opacity: .5; counter-increment: n; }

/* Admin add button */
#fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  width: min(calc(100% - 32px), 488px); height: 58px; border-radius: 20px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 17px;
  box-shadow: 0 12px 30px rgba(52, 211, 153, .28);
}
#fab:active { transform: translateX(-50%) scale(.98); }

/* Bottom sheet */
#overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .6);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
#sheet {
  width: 100%; max-width: 520px; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--card); border-radius: 26px 26px 0 0; border: 1px solid var(--line); border-bottom: 0;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 16px);
  animation: up .24s cubic-bezier(.2, .8, .2, 1);
}
.sheet-grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 20px; font-weight: 800; }
.link { color: var(--mute); font-weight: 600; padding: 10px 2px; }
.link.strong { color: var(--accent); }

#new-player { display: flex; gap: 8px; margin-bottom: 12px; }
input {
  flex: 1; min-width: 0; height: 52px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--bg); padding: 0 16px; outline: none;
}
input:focus { border-color: var(--accent); }
#new-player button, .login-card button {
  height: 52px; padding: 0 20px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 800;
}

#sheet-label {
  margin: 4px 2px 6px; font-size: 12px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--mute);
}
#sheet-list { overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; }
.prow { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.prow:first-child { border-top: 0; }
.pill {
  height: 42px; padding: 0 12px; border-radius: 12px; background: var(--card2);
  color: var(--mute); font-weight: 700; font-size: 14px; flex: none;
}
.pill.on-in { background: var(--accent); color: var(--accent-ink); }
.pill.on-wait { background: var(--warn); color: #1c1400; }
.pill.del { background: rgba(248, 113, 113, .14); color: var(--danger); }
.star { width: 30px; height: 42px; margin: 0 -4px 0 -6px; flex: none; font-size: 22px; line-height: 1; color: var(--mute); opacity: .6; }
.star.on { color: var(--warn); opacity: 1; }
.prow .pill { padding: 0 10px; }
.empty { color: var(--mute); text-align: center; padding: 26px 0; font-size: 15px; }

/* Login */
#login { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.login-card h2 { margin: 0; font-size: 26px; }
.login-card p { margin: 0; color: var(--mute); }
.login-card input { flex: none; text-align: center; font-size: 22px; letter-spacing: .3em; }
.login-card a { color: var(--mute); font-size: 14px; margin-top: 6px; }
.spade.big { font-size: 54px; line-height: 1; }
.err { color: var(--danger) !important; min-height: 1.4em; font-size: 14px; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 14px); z-index: 40;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px;
  padding: 10px 16px; border-radius: 99px; max-width: calc(100% - 32px);
}

@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
