body {
  min-height: 100%;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255, 61, 139, 0.18), transparent 60%),
    var(--night);
  padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior: none;
}

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(13, 10, 31, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar .logo { font-size: 20px; flex: 1; min-width: 0; white-space: nowrap; }
.room-chip {
  font-family: var(--display); font-size: 14px; letter-spacing: 0.08em; color: var(--amber);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.join-form { display: grid; gap: 4px; margin-top: 8px; }
.join-form input {
  background: var(--panel); border: 1px solid var(--line); color: var(--ink); border-radius: 16px;
  padding: 16px; font-family: var(--display); font-size: 40px; text-align: center; letter-spacing: 0.2em;
  text-transform: uppercase; width: 100%;
}
.join-form input::placeholder { color: rgba(166, 156, 201, 0.3); }
.join-form input:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); font-size: 18px;
}

.view { padding: 16px; max-width: 520px; margin: 0 auto; }
h1 { font-family: var(--display); font-weight: 400; font-size: 28px; margin: 8px 0 4px; }
.hint { color: var(--ink-dim); margin: 0 0 16px; }
.hint.small { font-size: 13px; margin-top: 18px; text-align: center; }
.hint b { color: var(--cyan); font-weight: 500; word-break: break-all; }

button.primary, button.ghost, button.danger {
  display: block; width: 100%;
  border-radius: 16px; padding: 14px; font-weight: 700; font-size: 16px;
  border: 1px solid var(--line);
}
button.primary {
  background: linear-gradient(180deg, var(--pink), #d71f6b);
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(255, 61, 139, 0.35);
}
button.primary.big { padding: 18px; font-size: 19px; margin-top: 12px; font-family: var(--display); font-weight: 400; letter-spacing: 0.04em; }
button.ghost { background: transparent; color: var(--ink); margin-top: 10px; }
button.danger { background: transparent; color: var(--pink); border-color: rgba(255, 61, 139, 0.4); }
button:active { transform: scale(0.98); }

/* names */
.names { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; counter-reset: n; }
.names li { display: flex; gap: 8px; align-items: center; counter-increment: n; }
.names li::before {
  content: counter(n); width: 28px; text-align: center;
  font-family: var(--display); color: var(--amber);
}
.names input {
  flex: 1; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  border-radius: 14px; padding: 14px; font: inherit; font-size: 17px;
}
.names input:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
.names .rm { width: 44px; height: 48px; border-radius: 14px; border: 1px solid var(--line); background: transparent; color: var(--ink-dim); font-size: 18px; }

/* now bowling */
.now {
  text-align: center; padding: 18px 12px 14px; border-radius: 22px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
}
.now-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.2em; color: var(--ink-dim); }
.now-name {
  font-family: var(--display); font-size: clamp(28px, 10vw, 44px); line-height: 1.1; margin: 4px 0 6px;
  color: var(--amber); text-shadow: 0 0 18px rgba(255, 197, 49, 0.35);
  overflow-wrap: anywhere;
}
.now-meta { color: var(--ink-dim); font-weight: 500; }
.now-meta .dot { opacity: 0.5; margin: 0 6px; }
#nowTotal { color: var(--ink); }
.standing {
  display: inline-block; margin-top: 12px; padding: 6px 12px; border-radius: 999px;
  background: rgba(41, 227, 255, 0.12); color: var(--cyan); font-weight: 700; font-size: 14px;
}

/* keypad */
.pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px;
}
.pad button {
  aspect-ratio: 1 / 0.72; border-radius: 18px; border: 1px solid var(--line);
  background: var(--panel); font-family: var(--display); font-size: 30px;
  transition: transform 0.08s, background 0.15s;
}
.pad button:active:not(:disabled) { transform: scale(0.94); background: var(--panel-2); }
.pad button:disabled { opacity: 0.18; }
.pad button.gutter { color: var(--ink-dim); }
.pad button small { display: block; font-family: var(--body); font-size: 12px; font-weight: 700; opacity: 0.7; letter-spacing: 0.04em; }
.pad button.mark {
  grid-column: span 2; aspect-ratio: auto; font-size: 22px;
  background: linear-gradient(180deg, var(--cyan), #0fb3d1); color: #04222a; border-color: transparent;
  box-shadow: 0 8px 24px rgba(41, 227, 255, 0.3);
}
.pad button.mark.strike { background: linear-gradient(180deg, var(--amber), #f09a10); box-shadow: 0 8px 24px rgba(255, 197, 49, 0.35); color: #2a1600; }
.pad.busy { pointer-events: none; opacity: 0.6; }

.row-actions { margin-top: 4px; }

/* mini scoreboard */
.mini { margin-top: 18px; display: grid; gap: 8px; }
.mini-row {
  border-radius: 14px; background: var(--night-2); border: 1px solid var(--line); padding: 8px 10px;
}
.mini-row.cur { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber) inset; }
.mini-head { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px; }
.mini-head .t { font-family: var(--display); font-weight: 400; color: var(--amber); }
.mini-frames { display: grid; grid-template-columns: repeat(9, 1fr) 1.4fr; gap: 2px; }
.mf { background: var(--panel); border-radius: 6px; text-align: center; padding: 3px 0; min-width: 0; }
.mf .m { font-size: 11px; letter-spacing: 1px; color: var(--ink-dim); height: 14px; white-space: nowrap; }
.mf .s { font-size: 12px; font-weight: 700; height: 15px; }
.mf.active { background: var(--panel-2); outline: 1px solid var(--cyan); }

/* results */
.results { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.results li {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line); font-size: 18px; font-weight: 700;
}
.results li .place { font-family: var(--display); color: var(--ink-dim); width: 28px; }
.results li .nm { flex: 1; overflow-wrap: anywhere; }
.results li .sc { font-family: var(--display); font-size: 24px; color: var(--amber); }
.results li:first-child { border-color: var(--amber); background: linear-gradient(90deg, rgba(255, 197, 49, 0.18), var(--panel)); }
.results li:first-child .place { color: var(--amber); }

/* menu sheet */
.sheet {
  position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 520px; background: var(--night-2); border-top: 1px solid var(--line);
  border-radius: 24px 24px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: grid; gap: 10px;
}
.sheet-card button {
  text-align: left; padding: 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--panel); font-weight: 500; font-size: 16px; margin: 0;
}
.sheet-card button.ghost { text-align: center; background: transparent; }
.sheet-card button.danger { color: var(--pink); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: 488px; margin: 0 auto; padding: 14px 16px; border-radius: 14px;
  background: var(--pink); color: #fff; font-weight: 700; text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* Apple TV guide */
.sheet-card.guide { max-height: 88vh; overflow-y: auto; gap: 12px; }
.guide h2 { font-family: var(--display); font-weight: 400; font-size: 22px; margin: 4px 0 0; }
.guide .hint { margin: 0; font-size: 14px; }
.guide .hint b { color: var(--ink); word-break: normal; }
.link-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.small-left { font-size: 12px !important; text-transform: uppercase; letter-spacing: 0.14em; }
.link { color: var(--cyan); font-weight: 700; font-size: 17px; margin: 4px 0 10px; word-break: break-all; user-select: all; }
.link-actions { display: flex; gap: 8px; }
.sheet-card .link-actions button { flex: 1; margin: 0; padding: 12px; text-align: center; font-size: 14px; background: transparent; }
.guide details { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.guide summary { font-weight: 700; cursor: pointer; }
.guide summary .tag { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; background: var(--amber); color: var(--night); padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.guide ol { margin: 10px 0 8px; padding-left: 20px; display: grid; gap: 6px; font-size: 15px; line-height: 1.4; }
.guide ol b { color: var(--amber); font-weight: 700; }
