:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7e7c9;
  color: #2b2119;
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100dvh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 20% 12%, rgba(255, 255, 255, 0.65), transparent 28%),
    linear-gradient(180deg, #ffe2ac 0%, #f8c97f 56%, #e99d5e 100%);
  overflow-x: hidden;
}

.game-shell {
  position: relative;
  width: min(960px, 100%);
  max-height: 100%;
  overflow: hidden;
}

.game-stage {
  position: relative;
}

.rotate-message {
  display: none;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.hud > div {
  padding: 10px 12px;
  border: 2px solid #38261a;
  border-radius: 8px;
  background: rgba(255, 250, 234, 0.82);
  box-shadow: 0 3px 0 rgba(70, 43, 22, 0.2);
  backdrop-filter: blur(3px);
}

.label {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #775435;
}

strong {
  display: block;
  font-size: clamp(1.05rem, 3vw, 1.55rem);
  line-height: 1;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 24 / 13;
  border: 3px solid #38261a;
  border-radius: 8px;
  background: #9cdaff;
  box-shadow: 0 12px 0 rgba(70, 43, 22, 0.22);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  min-width: 0;
  border: 2px solid #38261a;
  border-radius: 8px;
  padding: 12px 18px;
  background: #fff6dd;
  color: #2b2119;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0 #8f5a2c;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #8f5a2c;
}

.name-form {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 10;
  display: grid;
  width: min(340px, calc(100% - 28px));
  gap: 12px;
  padding: 18px;
  border: 3px solid #38261a;
  border-radius: 8px;
  background: #fff6dd;
  box-shadow: 0 10px 0 rgba(70, 43, 22, 0.3);
  transform: translate(-50%, -50%);
}

.name-form[hidden] {
  display: none;
}

.name-form label {
  font-weight: 900;
  text-align: center;
}

.name-form input {
  width: 100%;
  border: 2px solid #38261a;
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  color: #2b2119;
  font: inherit;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

@media (max-width: 560px) {
  body {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .game-shell {
    width: 100%;
  }

  .hud {
    gap: 6px;
    margin-bottom: 8px;
  }

  .hud > div {
    padding: 7px 6px;
    box-shadow: 0 3px 0 rgba(70, 43, 22, 0.25);
  }

  .label {
    font-size: 0.58rem;
    letter-spacing: 0.04em;
  }

  strong {
    font-size: clamp(1rem, 5vw, 1.45rem);
  }

  canvas {
    max-width: 100%;
    border-width: 2px;
    box-shadow: 0 7px 0 rgba(70, 43, 22, 0.22);
  }

  .name-form {
    top: 46%;
    padding: 14px;
  }

  .name-form input {
    font-size: 16px;
  }
}

@media (orientation: landscape) and (max-height: 520px) and (pointer: fine) {
  body {
    padding: 6px;
  }

  .game-shell {
    width: min(100%, 1100px);
  }

  canvas {
    max-height: calc(100svh - 68px);
  }
}
