:root {
  --lcd: #9ead86;
  --lcd-dark: #0f380f;
  --lcd-mid: #8a9a71;
  --body: #262c33;
  --body-dark: #14181d;
  --key: #2e343c;
  --key-face: #3a414b;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 16px;
  background: radial-gradient(circle at 50% 25%, #1c2532, #0a0d12 70%);
  font-family: 'Press Start 2P', monospace;
  color: var(--lcd);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.phone {
  width: min(430px, 100%);
  padding: 22px 18px 24px;
  border: 1px solid #000;
  border-radius: 38px;
  background: linear-gradient(180deg, var(--body), var(--body-dark));
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -2px 0 rgba(0, 0, 0, 0.5);
}

.phone-top {
  margin-bottom: 14px;
  text-align: center;
}

.speaker {
  width: 70px;
  height: 6px;
  margin: 0 auto 9px;
  border-radius: 3px;
  background: #0a0c0f;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.9);
}

.brand {
  font-size: 8px;
  letter-spacing: 3px;
  color: #67707c;
}

.lcd-frame {
  padding: 12px;
  border-radius: 20px;
  background: #0b0d10;
  box-shadow:
    inset 0 3px 12px rgba(0, 0, 0, 0.8),
    0 1px 0 rgba(255, 255, 255, 0.05);
}

.lcd {
  overflow: hidden;
  border-radius: 10px;
  background: var(--lcd);
}

.lcd-bar {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px 6px;
  font-size: 8px;
  color: var(--lcd-dark);
  border-bottom: 3px solid var(--lcd-mid);
}

.screen {
  position: relative;
  touch-action: none;
}

.screen canvas {
  display: block;
  width: 100%;
  height: auto;
  background: var(--lcd);
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.screen::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(15, 56, 15, 0.045) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at 30% 15%, rgba(255, 255, 255, 0.1), transparent 60%);
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  background: rgba(158, 173, 134, 0.95);
  color: var(--lcd-dark);
}

#overlay.hidden {
  display: none;
}

.ov-snake {
  width: 10px;
  height: 10px;
  margin: 0 auto 14px;
  background: var(--lcd-dark);
  box-shadow:
    14px 0 0 var(--lcd-dark),
    28px 0 0 var(--lcd-dark),
    42px 0 0 var(--lcd-dark),
    56px 0 0 var(--lcd-dark);
  transform: translateX(28px);
}

.ov-title {
  font-size: 32px;
  letter-spacing: 2px;
  text-shadow: 3px 3px 0 rgba(15, 56, 15, 0.22);
}

.ov-title-2 {
  margin-bottom: 16px;
  font-size: 16px;
  letter-spacing: 1px;
}

.ov-label {
  margin: 10px 0 4px;
  font-size: 8px;
  opacity: 0.85;
}

.diff-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 8px 0;
}

.diff {
  padding: 9px 7px;
  border: 3px solid var(--lcd-dark);
  border-radius: 4px;
  background: transparent;
  color: var(--lcd-dark);
  font-family: inherit;
  font-size: 8px;
  cursor: pointer;
}

.diff:hover {
  background: rgba(15, 56, 15, 0.15);
}

.diff.sel,
.diff.sel:hover {
  background: var(--lcd-dark);
  color: var(--lcd);
  box-shadow: 2px 2px 0 rgba(15, 56, 15, 0.35);
}

.ov-btn {
  margin: 10px 0 4px;
  padding: 13px 22px;
  border: none;
  border-radius: 4px;
  background: var(--lcd-dark);
  color: var(--lcd);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(15, 56, 15, 0.35);
}

.ov-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(15, 56, 15, 0.35);
}

.ov-btn.ghost {
  margin-top: 8px;
  background: transparent;
  color: var(--lcd-dark);
  border: 3px solid var(--lcd-dark);
  font-size: 8px;
  padding: 10px 16px;
}

.ov-score {
  margin: 8px 0;
  font-size: 16px;
  line-height: 1.8;
}

.ov-score.dim {
  font-size: 8px;
  opacity: 0.65;
}

.ov-record {
  display: inline-block;
  margin: 6px 0;
  padding: 6px 10px;
  background: var(--lcd-dark);
  color: var(--lcd);
  font-size: 8px;
  animation: blink 0.9s step-end infinite;
}

.ov-keys {
  margin-top: 12px;
  font-size: 7px;
  line-height: 2.1;
  opacity: 0.7;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding: 0 6px;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 4px;
}

.dpad button {
  border: 1px solid #14171c;
  border-radius: 8px;
  background: var(--key-face);
  color: #9fb0c4;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  box-shadow:
    0 3px 0 #14171c,
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  touch-action: manipulation;
}

.dpad button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #14171c;
}

.k-up {
  grid-area: 1 / 2;
}

.k-left {
  grid-area: 2 / 1;
}

.k-center {
  grid-area: 2 / 2;
  border-radius: 50%;
  background: var(--key);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.6);
}

.k-right {
  grid-area: 2 / 3;
}

.k-down {
  grid-area: 3 / 2;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.actions button {
  width: 66px;
  height: 40px;
  border: 1px solid #14171c;
  border-radius: 20px;
  background: linear-gradient(180deg, #4a5b74, #35435a);
  color: #cfe0f4;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  box-shadow:
    0 3px 0 #14171c,
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  touch-action: manipulation;
}

.actions button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #14171c;
}

@media (max-width: 400px) {
  .phone {
    padding: 18px 12px 20px;
  }

  .dpad {
    grid-template-columns: repeat(3, 46px);
    grid-template-rows: repeat(3, 46px);
  }

  .ov-title {
    font-size: 24px;
  }
}
