:root {
  --app-height: 100svh;
  --gold: #f8c85d;
  --gold-dark: #b56b1f;
  --ink: #16072d;
  --violet: #4e238f;
  --rose: #d93f7b;
  --cream: #fff3cf;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  background:
    radial-gradient(circle at 30% 10%, rgba(86, 57, 171, 0.65), transparent 30%),
    linear-gradient(145deg, #09051a, #16072d 55%, #2b103b);
  color: var(--cream);
  font-family: "Baloo 2", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  height: var(--app-height);
  min-height: var(--app-height);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: grid;
  place-items: center;
}

button {
  border: 0;
  border-radius: 8px;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

audio {
  display: none;
}

.phone-shell {
  position: relative;
  width: min(100vw, calc(var(--app-height) * 0.462));
  height: var(--app-height);
  max-height: 940px;
  min-height: 620px;
  overflow: hidden;
  background: #11062c;
  box-shadow: 0 0 0 1px rgba(255, 221, 130, 0.22), 0 28px 70px rgba(0, 0, 0, 0.45);
  isolation: isolate;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #12072f;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 24px max(20px, env(safe-area-inset-bottom));
  text-align: center;
  background: linear-gradient(180deg, rgba(8, 4, 25, 0.36), rgba(8, 4, 25, 0.14) 42%, rgba(8, 4, 25, 0.52));
}

.screen.is-active {
  display: flex;
}

.audio-buttons {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 16px;
  z-index: 3;
  display: flex;
  gap: 8px;
}

.sound-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(248, 200, 93, 0.82);
  background: rgba(37, 16, 80, 0.78);
  color: var(--gold);
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 218, 120, 0.22), 0 10px 22px rgba(0, 0, 0, 0.28);
}

#sfxButton {
  font-size: 0.78rem;
  letter-spacing: 0;
}

#sfxButton.is-muted {
  font-size: 1.6rem;
}

.lock-button {
  position: absolute;
  left: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 3;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border: 2px solid rgba(248, 200, 93, 0.6);
  background: rgba(27, 12, 66, 0.68);
  color: transparent;
  font-size: 0;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

.lock-button::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 17px;
  width: 18px;
  height: 15px;
  transform: translateX(-50%);
  border-radius: 4px;
  background: var(--gold);
  box-shadow: inset 0 -3px 0 rgba(181, 107, 31, 0.85);
}

.lock-button::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 8px;
  width: 15px;
  height: 16px;
  transform: translateX(-50%);
  border: 3px solid var(--gold);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
}

.sound-button .sound-off {
  display: none;
}

.sound-button.is-muted .sound-on {
  display: none;
}

.sound-button.is-muted .sound-off {
  display: block;
}

.brand {
  margin-top: auto;
  transform: translateY(-18px);
}

.kicker {
  display: block;
  color: var(--gold);
  font-family: "Cinzel", Georgia, serif;
  font-size: clamp(0.78rem, 3.2vw, 0.95rem);
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(75, 31, 95, 0.85);
}

h1,
h2 {
  margin: 0;
  color: #fff6d6;
  font-family: "Cinzel", Georgia, serif;
  line-height: 0.95;
  text-shadow: 0 3px 0 #6b2d73, 0 0 18px rgba(248, 200, 93, 0.45);
}

h1 {
  max-width: 9ch;
  font-size: clamp(3.05rem, 15vw, 4.65rem);
}

h2 {
  font-size: clamp(2rem, 9.5vw, 3.05rem);
}

.menu-panel h2 {
  max-width: 100%;
  font-size: clamp(1.55rem, 7.2vw, 2.2rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.menu-panel {
  width: min(100%, 300px);
  padding: 20px;
  border: 3px solid var(--gold-dark);
  border-radius: 8px;
  background: rgba(37, 16, 80, 0.84);
  box-shadow: inset 0 0 0 2px rgba(255, 218, 120, 0.28), 0 18px 40px rgba(0, 0, 0, 0.28);
}

.form-panel,
.list-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-panel {
  width: min(100%, 340px);
  max-height: calc(100% - 58px);
  overflow: hidden;
}

.player-name {
  margin: 0 0 4px;
  color: rgba(255, 243, 207, 0.9);
  font-size: 1.02rem;
  font-weight: 800;
}

.best-label {
  margin: 0;
  color: var(--gold);
  font-family: "Cinzel", Georgia, serif;
  font-size: 1rem;
  text-transform: uppercase;
}

.best-score {
  margin: 0 0 16px;
  color: #fff7dc;
  font-size: 4.4rem;
  font-weight: 800;
  line-height: 0.9;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}

.best-score.small {
  font-size: 3.1rem;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 54px;
  margin-top: 10px;
  padding: 12px 18px;
  font-weight: 800;
  text-transform: uppercase;
  box-shadow: 0 5px 0 rgba(64, 26, 71, 0.95), 0 11px 24px rgba(0, 0, 0, 0.28);
}

.primary-button {
  background: linear-gradient(180deg, #ffe083, #e1902d);
  color: #3d184e;
}

.secondary-button {
  background: rgba(255, 246, 214, 0.12);
  border: 2px solid rgba(248, 200, 93, 0.72);
  color: var(--cream);
}

.danger-button {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  padding: 10px 14px;
  border: 2px solid rgba(255, 202, 94, 0.72);
  background: linear-gradient(180deg, #b7354b, #741f43);
  color: #fff7dc;
  font-weight: 800;
  text-transform: uppercase;
}

.text-input,
.score-input {
  width: 100%;
  min-height: 48px;
  border: 2px solid rgba(248, 200, 93, 0.72);
  border-radius: 8px;
  background: rgba(255, 246, 214, 0.12);
  color: #fff7dc;
  font: inherit;
  font-weight: 800;
  text-align: center;
  outline: none;
}

.text-input:focus,
.score-input:focus {
  border-color: #ffe083;
  box-shadow: 0 0 0 3px rgba(248, 200, 93, 0.22);
}

.leaderboard-list {
  min-height: 240px;
  max-height: 380px;
  margin: 6px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  text-align: left;
}

.leaderboard-row,
.admin-row {
  display: grid;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(248, 200, 93, 0.18);
}

.leaderboard-row {
  grid-template-columns: 32px 1fr auto;
}

.rank {
  color: var(--gold);
  font-weight: 800;
}

.leader-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.leader-score {
  color: #fff7dc;
  font-size: 1.25rem;
  font-weight: 800;
}

.panel-status {
  min-height: 18px;
  margin: 4px 0 0;
  color: rgba(255, 243, 207, 0.78);
  font-size: 0.88rem;
  line-height: 1.2;
}

.admin-login {
  display: grid;
  gap: 8px;
}

.admin-panel {
  min-height: 220px;
  overflow: hidden;
}

.admin-rows {
  max-height: 300px;
  overflow-y: auto;
}

.admin-row {
  grid-template-columns: 1fr 74px 34px;
}

.admin-row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-weight: 800;
}

.score-input {
  min-height: 38px;
  padding: 4px;
}

.admin-delete {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid rgba(248, 200, 93, 0.5);
  background: rgba(116, 31, 67, 0.78);
  color: #fff7dc;
  font-size: 1.2rem;
  font-weight: 800;
}

.credit {
  width: 100%;
  margin: auto 0 0;
  color: rgba(255, 243, 207, 0.82);
  text-decoration: none;
  line-height: 1.2;
}

.credit-love,
.credit-by {
  display: block;
}

.credit-love {
  color: #fff3cf;
  font-size: 1.2rem;
  font-weight: 800;
}

.credit-by {
  margin-top: 2px;
  color: rgba(255, 243, 207, 0.86);
  font-size: 1.04rem;
  font-weight: 700;
}

@supports (height: 100dvh) {
  :root {
    --app-height: 100dvh;
  }
}

@media (min-width: 620px) {
  body {
    padding-block: 18px;
  }

  .phone-shell {
    height: min(100%, 844px);
    border-radius: 8px;
  }
}
