* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: #07060d; color: #f3ead2; font-family: Georgia, 'Times New Roman', serif;
  overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#stage { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#hud {
  position: absolute; inset: 0; margin: auto; display: block; pointer-events: none;
  width: min(100vw, calc(100dvh * 16 / 9)); height: auto; aspect-ratio: 16 / 9;
}

.screen {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 12px;
  background: radial-gradient(ellipse at center, rgba(16, 10, 32, .55), rgba(4, 3, 10, .85));
  padding: 16px; text-align: center;
}
.screen.overlay { background: rgba(4, 3, 10, .7); }
.hidden { display: none !important; }

h1 { font-size: clamp(36px, 7vw, 84px); margin: 0; letter-spacing: .12em; color: #f4d27a; text-shadow: 0 0 24px rgba(244, 210, 122, .45); }
h1 span { color: #b99cff; text-shadow: 0 0 24px rgba(185, 156, 255, .55); }
h2 { font-size: clamp(24px, 4vw, 48px); margin: 0; color: #f4d27a; }
.tag { margin: -6px 0 4px; opacity: .75; font-style: italic; }

.name { display: flex; gap: 8px; align-items: center; }
input { font: inherit; padding: 8px 12px; border-radius: 8px; border: 1px solid #6a5a99; background: #140f26; color: #f3ead2; }
input:focus { outline: 2px solid #b99cff; }

#roster { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.card {
  width: 150px; padding: 10px; border-radius: 12px; cursor: pointer;
  background: #120d22; border: 2px solid #2a2244; transition: transform .12s, border-color .12s;
}
.card:hover { transform: translateY(-3px); }
.card.sel { border-color: var(--c); box-shadow: 0 0 18px var(--c); }
.card canvas { width: 100%; height: auto; aspect-ratio: 1; }
.card b { display: block; color: var(--c); }
.card small { display: block; opacity: .8; font-size: 11px; line-height: 1.3; }
.card i { display: block; font-size: 12px; color: #f4d27a; }

.buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }
button {
  font: inherit; font-size: 16px; padding: 10px 18px; border-radius: 10px; cursor: pointer;
  background: #221a3d; color: #f3ead2; border: 1px solid #6a5a99;
}
button:hover { background: #2f2454; }
button.primary { background: linear-gradient(#8a5cf5, #5a32c7); border-color: #c8b4ff; font-weight: bold; }
.join { display: flex; gap: 6px; }
.join input { width: 90px; text-transform: uppercase; text-align: center; letter-spacing: .2em; }

.controls { font-size: 12.5px; opacity: .85; max-width: 860px; line-height: 1.55; }
.error { color: #ff7a7a; min-height: 1em; margin: 0; }

.code { font-size: 64px; letter-spacing: .3em; color: #b99cff; font-weight: bold; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid #2a2244; border-top-color: #b99cff; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#btn-quit { position: absolute; top: 10px; right: 10px; font-size: 13px; padding: 6px 12px; opacity: .7; }

.solo { margin-top: -2px; }
.solo-label { opacity: .8; font-style: italic; }
button.lvl { padding: 8px 14px; }
input, textarea { -webkit-user-select: text; user-select: text; }

/* keyboard vs touch help text */
body.touch .keys-only, body:not(.touch) .touch-only { display: none; }

/* ------------------------------------------------ touch controls */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#stick {
  position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom));
  width: 150px; height: 150px; border-radius: 50%; pointer-events: auto; touch-action: none;
  background: radial-gradient(circle, rgba(185,156,255,.12), rgba(185,156,255,.04));
  border: 2px solid rgba(185,156,255,.35);
}
#knob {
  position: absolute; left: 50%; top: 50%; width: 62px; height: 62px; margin: -31px 0 0 -31px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,.5), rgba(185,156,255,.45));
  border: 2px solid rgba(255,255,255,.5); pointer-events: none;
}
#tbtns {
  position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(2, 74px); grid-auto-rows: 74px; gap: 10px; pointer-events: none;
}
.tb {
  pointer-events: auto; touch-action: none; border-radius: 50%; padding: 0; font-size: 12px; font-weight: bold; letter-spacing: .04em;
  background: rgba(34,26,61,.55); border: 2px solid rgba(200,180,255,.5); color: #f3ead2;
  -webkit-tap-highlight-color: transparent;
}
.tb.down { background: rgba(138,92,245,.75); border-color: #fff; transform: scale(.94); }
#tb-ult, #tb-super { width: 54px; height: 54px; justify-self: center; align-self: end; opacity: .35; font-size: 13px; }
#tb-ult.ready, #tb-super.ready { opacity: 1; box-shadow: 0 0 18px #f4d27a; border-color: #f4d27a; }
#tb-super { font-size: 22px; }

#rotate {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; text-align: center; padding: 24px;
  background: rgba(4,3,10,.92); font-size: 22px; color: #f4d27a;
}

/* ------------------------------------------------ small screens (phones) */
@media (max-height: 560px), (max-width: 720px) {
  .screen { gap: 7px; padding: 10px max(10px, env(safe-area-inset-right)) 14px max(10px, env(safe-area-inset-left)); }
  h1 { font-size: 34px; }
  .tag { margin: -4px 0 0; font-size: 13px; }
  #roster { gap: 6px; flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding: 4px; justify-content: safe center; }
  .card { width: 112px; flex: 0 0 auto; padding: 6px; }
  .card canvas { width: 64px; }
  .card small { font-size: 9.5px; }
  button { font-size: 14px; padding: 8px 12px; }
  .controls { font-size: 11px; }
  .code { font-size: 44px; }
}

.credit { margin: 2px 0 0; font-size: 13px; opacity: .8; }
.credit a, .portfolio { color: #b99cff; }
.about-text { max-width: 520px; line-height: 1.5; opacity: .9; }
.about-maker { font-size: 20px; margin: 4px 0; }
.portfolio {
  font-size: 18px; padding: 10px 20px; border-radius: 10px; text-decoration: none;
  border: 1px solid #b99cff; background: rgba(185,156,255,.1);
}
.portfolio:hover { background: rgba(185,156,255,.22); }
.screen > * { flex-shrink: 0; }
body.touch #btn-quit { top: auto; right: auto; left: 50%; bottom: max(8px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6; }
