/* ─── RESET & BASE ─────────────────────────────────────── */

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

@font-face {
  font-family: 'DotGothic';
  src: url('https://fonts.gstatic.com/s/dotgothic16/v17/v6-QGYjBJFKgyw5nSoDAGE7L435YPFrT.woff2') format('woff2');
  font-display: swap;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: #1a1a2e;
  font-family: 'DotGothic', 'Courier New', monospace;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, #2a2a4a 0%, #1a1a2e 50%, #0d0d1a 100%);
}

/* ─── SEO CONTENT ──────────────────────────────────────── */

.seo-content {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ─── NAME INPUT OVERLAY ───────────────────────────────── */

.name-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 20, 0.85);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.name-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.name-dialog {
  background: linear-gradient(145deg, #e8e0d0, #c4b89e);
  border-radius: 20px;
  padding: 28px 32px;
  text-align: center;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.name-title {
  font-family: 'DotGothic', monospace;
  font-size: 16px;
  color: #3a3a3a;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

.name-input {
  display: block;
  width: 180px;
  padding: 8px 12px;
  font-family: 'DotGothic', monospace;
  font-size: 18px;
  text-align: center;
  border: 2px solid #8a7e68;
  border-radius: 8px;
  background: #f0e8d8;
  color: #3a3a3a;
  outline: none;
  margin: 0 auto 14px;
}

.name-input:focus {
  border-color: #5070d4;
  box-shadow: 0 0 0 3px rgba(80, 112, 212, 0.3);
}

.name-confirm {
  font-family: 'DotGothic', monospace;
  font-size: 14px;
  padding: 8px 32px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #50a850, #308030);
  color: #f0e8d8;
  cursor: pointer;
  box-shadow:
    0 3px 0 #206020,
    0 4px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.08s;
}

.name-confirm:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #206020;
}

/* ─── DEVICE SHELL ─────────────────────────────────────── */

.device {
  position: relative;
  width: 300px;
  height: 500px;
  background: linear-gradient(145deg, #e8e0d0 0%, #d4cbb8 30%, #c4b89e 70%, #b8a888 100%);
  border-radius: 140px 140px 100px 100px / 80px 80px 120px 120px;
  box-shadow:
    0 2px 0 #f0e8d8,
    0 -2px 0 #a89878,
    4px 0 0 #c4b898,
    -4px 0 0 #c4b898,
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.3),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 36px;
  user-select: none;
  -webkit-user-select: none;
}

.device::before {
  content: 'TAMAGOTCHI';
  position: absolute;
  top: 14px;
  font-family: 'DotGothic', monospace;
  font-size: 11px;
  letter-spacing: 4px;
  color: #8a7e68;
  text-transform: uppercase;
}

/* ─── SCREEN BEZEL ─────────────────────────────────────── */

.screen-bezel {
  position: relative;
  width: 220px;
  height: 195px;
  background: #3a3a3a;
  border-radius: 20px;
  padding: 14px;
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.6),
    inset 0 -1px 2px rgba(255, 255, 255, 0.05),
    0 1px 0 rgba(255, 255, 255, 0.15);
  margin-top: 8px;
}

.screen-bezel::after {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 8px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 2;
}

/* ─── LCD SCREEN ───────────────────────────────────────── */

.screen {
  position: relative;
  width: 192px;
  height: 160px;
  border-radius: 6px;
  overflow: hidden;
  image-rendering: pixelated;
  background: #9bbc0f;
}

.screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.04) 2px,
    rgba(0, 0, 0, 0.04) 4px
  );
  pointer-events: none;
  z-index: 1;
}

#game-canvas {
  display: block;
  width: 192px;
  height: 160px;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* ─── CONTROLS: D-PAD + A/B ────────────────────────────── */

.controls {
  display: flex;
  align-items: center;
  gap: 36px;
  margin-top: 20px;
}

/* D-Pad */
.dpad {
  display: grid;
  grid-template-columns: 32px 32px 32px;
  grid-template-rows: 32px 32px 32px;
  gap: 0;
  position: relative;
  /* Cross-shaped background so no gaps show */
  background:
    linear-gradient(180deg, #6a6050, #5a5040);
  clip-path: polygon(
    33.33% 0%, 66.66% 0%,
    66.66% 33.33%, 100% 33.33%,
    100% 66.66%, 66.66% 66.66%,
    66.66% 100%, 33.33% 100%,
    33.33% 66.66%, 0% 66.66%,
    0% 33.33%, 33.33% 33.33%
  );
  border-radius: 4px;
}

.dpad-btn {
  width: 32px;
  height: 32px;
  border: none;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.dpad-center {
  width: 32px;
  height: 32px;
  background: #6a6050;
}

.dpad-up {
  grid-column: 2;
  grid-row: 1;
  background: linear-gradient(180deg, #7a7060, #5a5040);
  border-radius: 6px 6px 0 0;
  box-shadow:
    0 -2px 0 #8a7e68,
    inset 0 2px 2px rgba(255, 255, 255, 0.15);
}

.dpad-down {
  grid-column: 2;
  grid-row: 3;
  background: linear-gradient(0deg, #7a7060, #5a5040);
  border-radius: 0 0 6px 6px;
  box-shadow:
    0 2px 0 #4a4030,
    inset 0 -2px 2px rgba(255, 255, 255, 0.1);
}

.dpad-left {
  grid-column: 1;
  grid-row: 2;
  background: linear-gradient(90deg, #7a7060, #5a5040);
  border-radius: 6px 0 0 6px;
  box-shadow:
    -2px 0 0 #8a7e68,
    inset 2px 0 2px rgba(255, 255, 255, 0.15);
}

.dpad-right {
  grid-column: 3;
  grid-row: 2;
  background: linear-gradient(-90deg, #7a7060, #5a5040);
  border-radius: 0 6px 6px 0;
  box-shadow:
    2px 0 0 #4a4030,
    inset -2px 0 2px rgba(255, 255, 255, 0.1);
}

/* Arrow indicators on d-pad */
.dpad-up::after {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 8px solid #a89878;
}

.dpad-down::after {
  content: '';
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #a89878;
}

.dpad-left::after {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid #a89878;
}

.dpad-right::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid #a89878;
}

.dpad-btn:active {
  filter: brightness(0.85);
}

/* A/B Buttons */
.ab-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.ab-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-family: 'DotGothic', monospace;
  font-size: 14px;
  font-weight: bold;
  color: #f0e8d8;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.06s;
  background: linear-gradient(180deg, #d45050 0%, #a83030 100%);
  box-shadow:
    0 3px 0 #8a2020,
    0 5px 10px rgba(0, 0, 0, 0.3),
    inset 0 1px 2px rgba(255, 200, 200, 0.3);
}

.ab-btn-b {
  width: 36px;
  height: 36px;
  font-size: 12px;
  background: linear-gradient(180deg, #888, #666);
  box-shadow:
    0 3px 0 #444,
    0 5px 10px rgba(0, 0, 0, 0.3),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.ab-btn:active {
  transform: scale(0.9) translateY(2px);
  box-shadow:
    0 1px 0 #8a2020,
    inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.ab-btn-b:active {
  box-shadow:
    0 1px 0 #444,
    inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ─── DECORATIVE ───────────────────────────────────────── */

.device-screw {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #c4b898, #a89878);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.3),
    inset 0 -1px 1px rgba(0, 0, 0, 0.2);
}

.device-screw::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 1px;
  width: 6px;
  height: 2px;
  background: #8a7e68;
  border-radius: 1px;
}

.screw-tl { top: 60px; left: 24px; }
.screw-tr { top: 60px; right: 24px; }
.screw-bl { bottom: 80px; left: 34px; }
.screw-br { bottom: 80px; right: 34px; }

.keychain-hole {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 12px;
  border: 3px solid #a89878;
  border-radius: 10px 10px 0 0;
  border-bottom: none;
  box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
}

.device-bottom-detail {
  position: absolute;
  bottom: 30px;
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, transparent, #b8a888, transparent);
  border-radius: 2px;
}

/* ─── FOOTER ───────────────────────────────────────────── */

.site-footer {
  position: fixed;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: 'DotGothic', monospace;
  font-size: 11px;
  color: #5a5a7a;
  letter-spacing: 0.5px;
}

.site-footer a {
  color: #8a8aaa;
  text-decoration: none;
  border-bottom: 1px dotted #5a5a7a;
  transition: color 0.2s;
}

.site-footer a:hover {
  color: #c0c0e0;
}

/* ─── RESPONSIVE ───────────────────────────────────────── */

@media (max-height: 600px) {
  .device {
    transform: scale(0.75);
    transform-origin: center center;
  }
}

@media (max-width: 360px) {
  .device {
    transform: scale(0.8);
    transform-origin: center center;
  }
}

/* ─── ANIMATION ────────────────────────────────────────── */

@keyframes subtle-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.device {
  animation: subtle-float 6s ease-in-out infinite;
}
