:root {
  color-scheme: dark;
  --button-bg: #00d6d6;
  --button-border: #737373;
  --gold: #ffdf00;
  --ink: #ffffff;
  --surface: #202020;
  --theme-hard: #202020;
  --theme-medium: #404040;
  --theme-soft: #404040;
  --theme-soft-hard: #303030;
  --theme-text: #ffffff;
  --theme-inverse-text: #000000;
  --theme-muted: #999999;
  --theme-muted-strong: #b8b8b8;
  --theme-border: #777777;
  --theme-shadow: rgb(0 0 0 / 24%);
  --theme-rainbow: conic-gradient(#ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
  --theme-button-fill: #202020;
}
html, body {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
* {
  box-sizing: border-box;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--theme-hard);
  color: var(--theme-text);
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.game {
  position: relative;
  display: grid;
  grid-template-rows: minmax(94px, auto) 1fr minmax(118px, auto);
  width: 100vw;
  height: 100dvh;
  min-height: 420px;
  overflow: hidden;
  background: var(--theme-hard);
  cursor: pointer;
}

.top-status {
  align-self: start;
  justify-self: center;
  width: min(92vw, 560px);
  max-height: calc(100dvh - 270px);
  overflow: hidden;
  padding-top: max(10px, env(safe-area-inset-top));
  text-align: center;
  pointer-events: none;
}

.help-button {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 3;
  width: 34px;
  height: 34px;
  border: 1px solid var(--theme-border);
  border-radius: 50%;
  background: var(--theme-soft);
  color: var(--theme-text);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.top-status p,
.pun-text {
  margin: 0;
}

.congratulations {
  margin-bottom: 8px;
  color: #1fab00;
  font-size: clamp(0.88rem, 2.3vw, 1.05rem);
}

.layer-list {
  display: grid;
  gap: 1px;
  min-height: calc(1.32em + 4px);
  max-height: calc(100dvh - 300px);
  overflow-y: auto;
  overscroll-behavior: contain;
  pointer-events: auto;
  background: var(--theme-medium);
  border: 1px solid var(--theme-border);
  border-radius: 25px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.layer-list::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
}

.layer-list::-webkit-scrollbar-thumb {
  background: transparent;
}

.layer-list::-webkit-scrollbar-track {
  background: transparent;
}
.layer-line {
  min-height: 1.32em;
  padding: 1px 8px;
  border-radius: 3px;
  font-size: clamp(0.9rem, 3vw, 1.2rem);
  line-height: 1.16;
  font-weight: 600;
  text-shadow: 0 1px 2px var(--theme-shadow);
}

.layer-line.hidden {
  display: none;
}

.layer-1 {
  color: #ff6800;
}

.layer-2 {
  color: #d49500;
}

.layer-3 {
  color: #e00000;
}

.layer-4 {
  color: #d900d9;
}

.layer-5 {
  color: #008f9b;
}

.layer-prime {
  color: #006bb8;
}

.layer-composite {
  color: #5b39b8;
}

.main-score {
  align-self: end;
  justify-self: center;
  width: min(96vw, 720px);
  min-height: 0;
  display: grid;
  place-items: center;
  font-size: clamp(7rem, 34vw, 13.5rem);
  line-height: 0.9;
  font-weight: 400;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--theme-text);
  padding-bottom: 10px;
  pointer-events: none;
}

.prestige-log-panel {
  position: absolute;
  top: 50%;
  right: max(10px, env(safe-area-inset-right));
  transform: translateY(-50%);
  z-index: 2;
  width: min(42vw, 230px);
  max-height: min(46vh, 340px);
  padding: 8px 9px;
  border: 1px solid var(--theme-border);
  border-radius: 6px;
  background: var(--theme-soft-hard);
  color: var(--theme-text);
  cursor: default;
}

.prestige-timer {
  margin-bottom: 6px;
  color: var(--theme-muted);
  font-size: 0.78rem;
  line-height: 1;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.prestige-log {
  display: grid;
  gap: 3px;
  max-height: calc(min(46vh, 340px) - 30px);
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 0.78rem;
  line-height: 1.18;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.prestige-log-header {
  margin-top: 6px;
  font-weight: 700;
}

.action-zone {
  align-self: end;
  justify-self: center;
  display: grid;
  grid-auto-flow: row;
  justify-items: center;
  gap: 10px;
  width: min(92vw, 620px);
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  text-align: center;
}

.pun-text {
  max-width: 100%;
  min-height: 2.4em;
  display: grid;
  place-items: end center;
  color: var(--theme-text);
  font-size: clamp(0.9rem, 2.6vw, 1rem);
  line-height: 1.25;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.prestige-button {
  min-width: 134px;
  min-height: 52px;
  padding: 0 18px;
  border: 2px solid var(--button-border);
  border-radius: 26px;
  background: var(--theme-button-fill);
  color: var(--button-bg);
  font-size: 1.08rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 5px var(--theme-shadow);
}

.prestige-button:active {
  transform: translateY(1px);
}

.plus-one {
  position: absolute;
  left: max(8px, env(safe-area-inset-left));
  bottom: max(8px, env(safe-area-inset-bottom));
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.plus-one img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.version-zone {
  position: absolute;
  left: max(10px, env(safe-area-inset-left));
  right: auto;
  top: max(8px, env(safe-area-inset-top));
  bottom: auto;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: min(58vw, 380px);
}

.control-stack {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.settings-shell {
  position: relative;
}

.game-version,
.fps-counter {
  color: var(--theme-muted);
  font-size: 0.78rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-align: left;
  pointer-events: none;
}

.update-button {
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--theme-border);
  border-radius: 4px;
  background: var(--theme-soft);
  color: var(--theme-text);
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
}

.update-button.hidden {
  display: none;
}

.settings-button,
.color-button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--theme-border);
  border-radius: 50%;
  background: var(--theme-soft);
  color: var(--theme-text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.color-button {
  background: var(--theme-rainbow);
}

.settings-menu {
  position: absolute;
  left: 0;
  right: auto;
  top: calc(100% + 8px);
  bottom: auto;
  z-index: 5;
  display: grid;
  gap: 6px;
  min-width: 132px;
  padding: 8px;
  border: 1px solid var(--theme-border);
  border-radius: 6px;
  background: var(--theme-soft-hard);
  color: var(--theme-text);
  box-shadow: 0 6px 18px var(--theme-shadow);
}

.color-menu {
  min-width: 174px;
  max-height: min(72vh, 430px);
  overflow-y: auto;
}

.menu-button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--theme-border);
  border-radius: 4px;
  background: var(--theme-hard);
  color: var(--theme-text);
  font-size: 0.8rem;
  line-height: 1;
  text-align: left;
  cursor: pointer;
}

.menu-button.active {
  border-color: var(--button-bg);
  color: var(--button-bg);
}

.color-option {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
}

.color-swatch {
  width: 18px;
  height: 18px;
  border: 1px solid var(--theme-border);
  border-radius: 50%;
  background: var(--swatch);
}

.menu-button.hidden {
  display: none;
}

.hidden {
  visibility: hidden;
  pointer-events: none;
}

.promo-dialog {
  width: min(88vw, 390px);
  padding: 0;
  border: 0;
  background: transparent;
}

.promo-dialog::backdrop {
  background: rgb(0 0 0 / 38%);
}

.promo-content {
  position: relative;
  padding: 18px 24px 20px;
  border: 7px solid var(--gold);
  border-radius: 10px;
  background: var(--theme-medium);
  color: var(--theme-text);
  text-align: center;
  cursor: default;
}

.promo-content h1 {
  margin: 0 32px 14px;
  color: var(--gold);
  font-size: 1.55rem;
  line-height: 1.1;
}

.promo-content p {
  margin: 0 0 18px;
  font-size: 1.05rem;
  line-height: 1.25;
  font-weight: 700;
}

.play-now {
  display: inline-grid;
  min-height: 44px;
  place-items: center;
  padding: 0 18px;
  border: 2px solid var(--gold);
  border-radius: 5px;
  background: var(--theme-hard);
  color: var(--gold);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 700;
}

.dialog-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--theme-text);
  font-size: 1.1rem;
  cursor: pointer;
}

.help-dialog {
  width: min(90vw, 420px);
  padding: 0;
  border: 0;
  background: transparent;
  margin: 0;
  position: fixed;
  inset: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) auto auto;
  z-index: 6;
}

.help-card {
  position: relative;
  padding: 18px 22px 20px;
  border: 2px solid var(--theme-border);
  border-radius: 8px;
  background: var(--theme-soft-hard);
  color: var(--theme-text);
  cursor: default;
}

.help-card h1 {
  margin: 0 34px 14px 0;
  font-size: 1.2rem;
  line-height: 1.1;
}

.help-card dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 14px;
  margin: 0;
  text-align: left;
}

.help-card dt {
  font-weight: 700;
}

.help-card dd {
  margin: 0;
  line-height: 1.25;
}

.import-dialog {
  width: min(92vw, 560px);
  padding: 0;
  border: 0;
  background: transparent;
}

.import-dialog::backdrop {
  background: rgb(0 0 0 / 38%);
}

.import-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 18px 22px 20px;
  border: 2px solid var(--theme-border);
  border-radius: 8px;
  background: var(--theme-soft-hard);
  color: var(--theme-text);
  cursor: default;
}

.import-card h1,
.import-card h2,
.import-copy {
  margin: 0;
}

.import-card h1 {
  margin-right: 34px;
  font-size: 1.2rem;
  line-height: 1.1;
}

.import-copy {
  color: var(--theme-muted-strong);
  line-height: 1.25;
}

.import-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.import-compare section {
  display: grid;
  gap: 6px;
}

.import-compare h2 {
  font-size: 0.92rem;
  line-height: 1.1;
}

.import-list {
  display: grid;
  gap: 6px;
  min-height: 92px;
  padding: 10px;
  border: 1px solid var(--theme-border);
  border-radius: 6px;
  background: var(--theme-hard);
  font-size: 0.9rem;
  line-height: 1.25;
}

.import-line {
  overflow-wrap: anywhere;
}

.import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.import-confirm {
  min-width: 132px;
}

@media (max-height: 560px) {
  .game {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .main-score {
    font-size: clamp(5.4rem, 28vh, 9rem);
  }

  .pun-text {
    min-height: 1.35em;
  }
}

@media (max-width: 640px) {
  .import-compare {
    grid-template-columns: 1fr;
  }

  .import-actions {
    flex-wrap: wrap;
  }
}
