body { height: 100dvh; overflow: hidden; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
}

.logo-sm {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--accent);
  text-shadow: 0 3px 0 #b89713;
}
.logo-sub { color: var(--dim); font-size: 13px; font-weight: 700; letter-spacing: 2px; margin-top: -12px; }

.hub { justify-content: center; gap: 22px; }

.hub-cards {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.hub-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(300px, 84vw);
  padding: 22px 20px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.12s, border-color 0.12s;
}
.hub-card:hover { transform: translateY(-3px); border-color: var(--accent); }

.hub-card-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--accent);
}

.hub-card-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--dim);
  text-align: center;
  min-height: 40px;
}

.hub-card-cta { pointer-events: none; }

#code-input {
  width: 190px;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 30px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 10px;
  outline: none;
}
#code-input:focus { border-color: var(--accent); }

.err-msg {
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
  min-height: 20px;
  text-align: center;
}

.shake { animation: shake 0.35s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-5px); }
}

.sec-title {
  align-self: flex-start;
  color: var(--dim);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 6px;
}

#screen-customize { justify-content: flex-start; overflow-y: auto; gap: 12px; }

.custom-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 420px;
}

.preview-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 18px;
}
#preview { image-rendering: pixelated; width: 96px; height: 96px; }

#name-input {
  width: 170px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
#name-input:focus { border-color: var(--accent); }

.swatches, .opt-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 420px;
}

.swatch {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 3px solid transparent;
  position: relative;
}
.swatch.sel { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,0.25); }
.swatch.taken { opacity: 0.25; pointer-events: none; }
.swatch.taken::after {
  content: '✕';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 18px;
}

.opt-btn {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  line-height: 0;
}
.opt-btn canvas { image-rendering: pixelated; }
.opt-btn.sel { border-color: var(--accent); }

#ready-btn { position: sticky; bottom: 8px; width: min(100%, 420px); }

.controller {
  justify-content: flex-start;
  padding: 0;
}

.ctrl-bar {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  background: rgba(23, 29, 44, 0.9);
}
.chip-btn { border: none; background: none; padding: 0; }

#status-line {
  flex: 1;
  text-align: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-hud {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 6px 12px;
  background: rgba(23, 29, 44, 0.75);
}
.hud-stat {
  font-weight: 800;
  font-size: 13px;
  color: var(--dim);
  white-space: nowrap;
}
#hud-score { color: var(--accent); }
#hud-rank { color: var(--ok, #6bcb77); }
#hud-status { color: var(--danger); }

.btn-exit {
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 1px;
}

.joy-zone {
  position: absolute;
  inset: 0;
  touch-action: none;
}

.joy-base {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 216px;
  height: 216px;
  margin: -108px 0 0 -108px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.18);
  pointer-events: none;
}
.joy-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 104px;
  height: 104px;
  margin: -52px 0 0 -52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  border: 2px solid rgba(255, 255, 255, 0.45);
}

.dash-wrap {
  position: absolute;
  right: 22px;
  bottom: max(34px, env(safe-area-inset-bottom));
  width: 96px;
  height: 96px;
  z-index: 2;
}
#dash-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc((1 - var(--cd, 0)) * 360deg), #333c52 0);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
#dash-btn::after {
  content: 'DASH';
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: #222b40;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--ink);
}
#dash-btn.ready::after { background: #3a4636; color: #b6f2b0; }
#dash-btn:active { filter: brightness(1.2); }

.throw-wrap {
  position: absolute;
  left: 22px;
  bottom: max(34px, env(safe-area-inset-bottom));
  width: 96px;
  height: 96px;
  z-index: 2;
}
#throw-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: conic-gradient(#8B6914 calc((1 - var(--cd, 0)) * 360deg), #333c52 0);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
#throw-btn::after {
  content: 'MUD';
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: #222b40;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--ink);
}
#throw-btn.ready::after { background: #3a3620; color: #f0d870; }
#throw-btn:active { filter: brightness(1.2); }

.fx-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 50;
  transition: opacity 0.15s;
}
.fx-overlay.frozen { background: rgba(120, 200, 255, 0.35); opacity: 1; }
.fx-overlay.stunned { background: rgba(255, 90, 95, 0.28); opacity: 1; }

.banner {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(20, 25, 40, 0.92);
  border: 1px solid var(--line);
  padding: 16px 26px;
  border-radius: 16px;
  font-weight: 900;
  font-size: 19px;
  text-align: center;
  animation: pop-in 0.25s ease-out;
  max-width: 86vw;
}

.controls-legend {
  position: absolute;
  top: max(112px, calc(env(safe-area-inset-top) + 96px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  pointer-events: none;
  background: rgba(16, 20, 31, 0.85);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--dim);
  line-height: 1.6;
  text-align: left;
}
.controls-legend .cl-title {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 2px;
  margin-bottom: 4px;
}
.controls-legend .cl-row {
  white-space: nowrap;
}
