:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  background: #ece9e1;
  color: #272a2c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  min-width: 0;
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
}

body {
  min-height: 100svh;
  display: grid;
  place-items: center;
  background: #ece9e1;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; }

.app {
  width: min(100vw, 430px);
  height: 100svh;
  min-height: 520px;
  max-height: 900px;
  position: relative;
  overflow: hidden;
  background: #d8d5cd;
  box-shadow: 0 0 34px rgba(36, 40, 42, .12);
}

.panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
  text-align: center;
  background:
    linear-gradient(rgba(255,255,255,.22), rgba(255,255,255,.08)),
    #d8d5cd;
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  color: #696c6c;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: clamp(38px, 12vw, 54px);
  line-height: 1;
  letter-spacing: -.06em;
  color: #25292a;
}

.howto {
  margin: 28px 0 34px;
  font-size: 15px;
  line-height: 1.9;
  font-weight: 650;
  color: #505556;
}

.primary-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  min-width: 176px;
  min-height: 54px;
  padding: 14px 28px;
  background: #283235;
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .04em;
  box-shadow: 0 5px 0 #182023, 0 9px 20px rgba(20, 25, 27, .16);
  cursor: pointer;
}

.primary-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #182023, 0 5px 14px rgba(20, 25, 27, .15);
}

.game-screen {
  position: absolute;
  inset: 0;
  background: #777b78;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.best {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: 12px;
  z-index: 2;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  color: rgba(255,255,255,.88);
  text-shadow: 0 1px 2px rgba(0,0,0,.22);
  pointer-events: none;
}

.swipe-hint {
  position: absolute;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 18px));
  z-index: 2;
  transform: translateX(-50%);
  padding: 9px 15px 10px;
  border-radius: 999px;
  background: rgba(35, 41, 42, .72);
  color: white;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  pointer-events: none;
  animation: hintPulse 1.2s ease-in-out infinite;
}

@keyframes hintPulse {
  0%,100% { transform: translateX(-50%) translateY(0); opacity: .78; }
  50% { transform: translateX(-50%) translateY(-5px); opacity: 1; }
}

.result-panel {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
  z-index: 4;
  padding: 18px 18px 20px;
  border-radius: 22px;
  background: rgba(247, 245, 239, .94);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  text-align: center;
  box-shadow: 0 14px 34px rgba(25, 29, 30, .22);
}

.result-main {
  font-size: clamp(27px, 9vw, 38px);
  line-height: 1;
  font-weight: 950;
  letter-spacing: -.03em;
  color: #252a2b;
}

.result-sub {
  margin: 9px 0 17px;
  font-size: 15px;
  font-weight: 750;
  color: #54595a;
}

.retry {
  min-width: 158px;
  min-height: 48px;
  padding: 11px 24px;
  font-size: 15px;
}

[hidden] { display: none !important; }

@media (max-width: 340px) {
  .app { min-height: 480px; }
  .panel { padding-left: 16px; padding-right: 16px; }
  .howto { font-size: 14px; }
  .result-panel { left: 10px; right: 10px; }
}
