@import url('https://fonts.googleapis.com/css2?family=Black+Han+Sans&family=Noto+Sans+SC:wght@400;600;800;900&display=swap');

:root {
  color-scheme: dark;
  font-family: "Noto Sans SC", sans-serif;
  background: #090d0b;
  color: #f5f1e8;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: none;
}

body {
  background:
    radial-gradient(circle at 72% 16%, rgba(131, 158, 88, .12) 0, transparent 32%),
    #090d0b;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
  overflow: hidden;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
}

.hidden {
  display: none !important;
}

.menu-screen {
  display: grid;
  align-content: center;
  padding: clamp(24px, 6vw, 92px);
  background:
    linear-gradient(90deg, rgba(9, 13, 11, .97) 0%, rgba(9, 13, 11, .9) 44%, rgba(9, 13, 11, .35) 100%),
    repeating-linear-gradient(115deg, transparent 0 80px, rgba(255, 255, 255, .018) 80px 82px);
}

.menu-screen::after {
  content: "VS";
  position: absolute;
  right: -1vw;
  top: 46%;
  color: rgba(255, 255, 255, .025);
  font-family: "Black Han Sans", sans-serif;
  font-size: min(38vw, 570px);
  line-height: .6;
  transform: translateY(-50%) rotate(-7deg);
  pointer-events: none;
}

.eyebrow {
  color: #c9f45b;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .35em;
  text-transform: uppercase;
}

h1 {
  position: relative;
  z-index: 1;
  margin: 12px 0 8px;
  font-family: "Black Han Sans", "Noto Sans SC", sans-serif;
  font-size: clamp(56px, 9.5vw, 132px);
  font-weight: 900;
  letter-spacing: -.07em;
  line-height: .75;
}

h1 span {
  color: #c9f45b;
  -webkit-text-stroke: 1px #c9f45b;
}

.intro {
  margin: 18px 0 20px;
  color: #9f9b91;
  font-size: clamp(13px, 1.35vw, 18px);
}

.mode-label {
  position: relative;
  z-index: 2;
  margin-bottom: 7px;
  color: #777d75;
  font: 700 9px monospace;
  letter-spacing: .22em;
}

.difficulty-label {
  margin-top: 17px;
}

.mode-list {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 252px));
  gap: 8px;
}

.mode-button {
  display: grid;
  grid-template-columns: 38px 1fr;
  grid-template-rows: auto auto;
  padding: 12px 14px;
  border: 1px solid #373d38;
  background: rgba(21, 27, 24, .88);
  color: #e8e7dc;
  text-align: left;
  cursor: pointer;
  transition: border-color .16s, background .16s, transform .16s;
}

.mode-button:hover,
.mode-button.selected {
  border-color: #c9f45b;
  background: rgba(201, 244, 91, .09);
  transform: translateY(-2px);
}

.mode-button b {
  grid-row: 1 / 3;
  align-self: center;
  color: #c9f45b;
  font: 900 15px monospace;
}

.mode-button span {
  font-size: 14px;
  font-weight: 900;
}

.mode-button small {
  margin-top: 2px;
  color: #777d75;
  font-size: 9px;
}

.difficulty-list {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, minmax(104px, 150px));
  gap: 8px;
}

.difficulty {
  position: relative;
  min-height: 116px;
  padding: 16px 14px 14px;
  overflow: hidden;
  border: 1px solid #37352f;
  background: rgba(25, 24, 21, .86);
  color: #f5f1e8;
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.difficulty::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 4px;
  background: var(--level-color);
  transform: scaleX(.2);
  transform-origin: left;
  transition: transform .18s ease;
}

.difficulty:hover,
.difficulty:focus-visible {
  z-index: 2;
  outline: none;
  border-color: var(--level-color);
  background: #24221d;
  transform: translateY(-6px);
}

.difficulty:hover::before,
.difficulty:focus-visible::before {
  transform: scaleX(1);
}

.difficulty b {
  display: block;
  margin-bottom: 10px;
  color: var(--level-color);
  font-family: "Black Han Sans", sans-serif;
  font-size: 25px;
}

.difficulty span,
.difficulty small {
  display: block;
}

.difficulty span {
  font-size: 17px;
  font-weight: 900;
}

.difficulty small {
  margin-top: 4px;
  color: #827f76;
  font-size: 11px;
}

.controls-hint {
  margin-top: 24px;
  color: #6f6c64;
  font-size: 12px;
}

kbd {
  display: inline-grid;
  min-width: 23px;
  height: 23px;
  margin-right: 3px;
  place-items: center;
  border: 1px solid #444139;
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #1b1a17;
  color: #bbb6aa;
  font-family: inherit;
  font-size: 10px;
}

.result-screen {
  display: grid;
  place-items: center;
  background: rgba(8, 8, 7, .86);
  backdrop-filter: blur(12px);
}

.round-result {
  display: grid;
  place-items: center;
  background: rgba(7, 10, 8, .82);
  backdrop-filter: blur(5px);
}

.round-result-card {
  width: min(520px, 88vw);
  padding: 46px 30px;
  border-top: 2px solid #c9f45b;
  border-bottom: 2px solid #c9f45b;
  background: rgba(14, 19, 16, .96);
  text-align: center;
}

.round-result-card p {
  margin: 0 0 7px;
  color: #8f968d;
  font: 700 10px monospace;
  letter-spacing: .28em;
}

.round-result-card h2 {
  margin: 0;
  color: #c9f45b;
  font-size: clamp(52px, 10vw, 92px);
  font-weight: 900;
  letter-spacing: -.08em;
}

.round-result-card strong {
  display: block;
  margin-top: 10px;
  color: #e8e7dc;
  font: 900 25px monospace;
}

.result-card {
  min-width: min(88vw, 520px);
  padding: 52px;
  border: 1px solid #37352f;
  background: #141310;
  text-align: center;
  box-shadow: 12px 12px 0 #080807;
}

.result-card h2 {
  margin: 8px 0 6px;
  font-size: clamp(48px, 9vw, 96px);
  font-weight: 900;
  letter-spacing: -.08em;
}

.final-score {
  margin-bottom: 28px;
  color: #89857c;
  font-family: "Black Han Sans", sans-serif;
  font-size: 28px;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.primary-button,
.text-button {
  padding: 12px 22px;
  border: 1px solid #c9f45b;
  cursor: pointer;
}

.primary-button {
  background: #c9f45b;
  color: #10150f;
  font-weight: 900;
}

.text-button {
  border-color: #403d36;
  background: transparent;
  color: #aaa69c;
}

.touch-controls {
  position: absolute;
  z-index: 5;
  inset: auto max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: none;
  justify-content: space-between;
  pointer-events: none;
}

.touch-group {
  display: flex;
  align-items: end;
  gap: 9px;
}

.touch-controls button {
  width: clamp(48px, 13vw, 58px);
  height: clamp(48px, 13vw, 58px);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 50%;
  background: rgba(15, 14, 12, .7);
  color: white;
  font-size: 18px;
  font-weight: 900;
  pointer-events: auto;
  backdrop-filter: blur(5px);
  user-select: none;
  -webkit-user-select: none;
}

.touch-controls button.active {
  background: #c9f45b;
  color: #10150f;
  transform: scale(.92);
}

.touch-controls button:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.touch-controls .attack-button {
  width: clamp(60px, 16vw, 70px);
  height: clamp(60px, 16vw, 70px);
  background: rgba(201, 244, 91, .78);
  color: #10150f;
}

@media (pointer: coarse), (max-width: 760px) {
  .touch-controls:not(.hidden) {
    display: flex;
  }

  .menu-screen {
    align-content: start;
    overflow-y: auto;
    padding: max(24px, env(safe-area-inset-top)) 18px 30px;
  }

  h1 {
    margin-top: 8px;
    font-size: clamp(50px, 17vw, 86px);
  }

  .intro {
    margin: 14px 0 18px;
  }

  .difficulty-list {
    grid-template-columns: 1fr 1fr;
  }

  .mode-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .mode-button {
    display: block;
    min-width: 0;
    padding: 10px 8px;
    text-align: center;
  }

  .mode-button b,
  .mode-button span,
  .mode-button small {
    display: block;
  }

  .mode-button b {
    margin-bottom: 3px;
  }

  .difficulty {
    min-height: 88px;
    padding: 11px 12px;
  }

  .difficulty:last-child {
    grid-column: 1 / -1;
  }

  .difficulty b {
    margin-bottom: 2px;
    font-size: 19px;
  }

  .controls-hint {
    display: none;
  }

  .result-card {
    padding: 38px 24px;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .menu-screen {
    grid-template-columns: minmax(230px, .8fr) 1.4fr;
    grid-template-rows: auto auto 1fr;
    column-gap: 28px;
    padding: 24px 36px;
  }

  .menu-screen .eyebrow,
  .menu-screen h1,
  .menu-screen .intro {
    grid-column: 1;
  }

  .menu-screen h1 {
    font-size: 62px;
  }

  .difficulty-list {
    grid-column: 2;
    grid-row: 1 / 4;
    align-self: center;
    grid-template-columns: repeat(3, 1fr);
  }

  .mode-list {
    grid-column: 1;
    align-self: end;
  }

  .mode-label,
  .difficulty-label {
    display: none;
  }

  .difficulty {
    min-height: 94px;
  }

  .controls-hint {
    display: none;
  }
}
