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

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1b3a6b 0%, #0d2818 55%, #1a472a 100%);
  font-family: 'Press Start 2P', monospace;
  color: #fff;
  image-rendering: pixelated;
}

#game-container {
  position: relative;
  border: 4px solid #ffe566;
  border-radius: 8px;
  box-shadow:
    0 0 0 4px #081c15,
    0 0 40px rgba(82, 183, 136, 0.4),
    inset 0 0 60px rgba(0, 0, 0, 0.3);
  background: #081c15;
}

#home-link {
  position: absolute;
  top: -28px;
  left: 0;
  font-size: 7px;
  color: #74c69d;
  text-decoration: none;
}

#home-link:hover {
  color: #fff;
}

#fullscreen-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 20;
  border: 2px solid #ffe566;
  border-radius: 4px;
  background: rgba(8, 28, 21, 0.82);
  color: #fff;
  padding: 7px 9px;
  font: 6px 'Press Start 2P', monospace;
  cursor: pointer;
}

#fullscreen-btn:hover {
  background: #40916c;
}

#game-container:fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #081c15;
}

#game-container:fullscreen #game {
  width: min(100vw, calc(100vh * 5 / 3));
  height: min(100vh, calc(100vw * 3 / 5));
}

#game-container:fullscreen #controls-help {
  bottom: 10px;
}

#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
}

#hud {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  pointer-events: none;
}

.hud-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  text-shadow: 2px 2px 0 #000;
  font-size: 8px;
  line-height: 1.6;
}

#message-box {
  margin-top: 4px;
  font-size: 7px;
  color: #ffd700;
  text-shadow: 2px 2px 0 #000;
  min-height: 16px;
}

#overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#overlay.hidden {
  display: none;
}

#overlay-content {
  background: #1b4332;
  border: 4px solid #52b788;
  padding: 24px;
  max-width: 90%;
  font-size: 8px;
  line-height: 2;
  text-align: center;
  max-height: 92%;
  overflow-y: auto;
}

#overlay-content h2 {
  color: #95d5b2;
  margin-bottom: 16px;
  font-size: 12px;
}

#overlay-content button {
  font-family: inherit;
  font-size: 8px;
  padding: 10px 20px;
  margin-top: 12px;
  background: #40916c;
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
}

#overlay-content button:hover {
  background: #52b788;
}

#overlay-content button:disabled {
  cursor: default;
  opacity: 0.75;
}

.shop-balance strong {
  color: #ffe566;
}

.shop-note {
  color: #b7e4c7;
  font-size: 6px;
  margin: 8px 0 12px;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 8px;
}

#overlay-content .shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0;
  text-align: left;
}

.shop-item small {
  color: #ffe566;
  font-family: inherit;
  font-size: 6px;
  white-space: nowrap;
}

#overlay-content .shop-item.equipped {
  background: #2d8a4a;
  outline: 2px solid #ffe566;
}

#overlay-content .shop-secondary {
  background: #315d4c;
  margin: 12px 4px 0;
}

.multi-note {
  color: #b7e4c7;
  margin: 8px 0;
}

.multi-error {
  color: #ff8fa3;
  margin: 8px 0;
}

.join-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

#overlay-content .join-row button {
  margin-top: 0;
}

#room-input {
  width: 180px;
  border: 3px solid #52b788;
  border-radius: 4px;
  background: #081c15;
  color: #ffe566;
  padding: 10px;
  font: 8px 'Press Start 2P', monospace;
  text-align: center;
  text-transform: uppercase;
}

.emote-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

#overlay-content .emote-grid button {
  min-height: 74px;
  margin: 0;
  line-height: 2;
}

.tail-meter {
  position: relative;
  width: min(460px, 72vw);
  height: 34px;
  margin: 18px auto;
  overflow: hidden;
  border: 3px solid #d8ffc2;
  background: #173b72;
}

.tail-fill {
  height: 100%;
  background: linear-gradient(90deg, #3185fc 0%, #ffe566 50%, #3dcc6a 100%);
  transition: width 70ms linear;
}

.tail-dori,
.tail-player {
  position: absolute;
  z-index: 1;
  top: 8px;
  font-size: 6px;
  text-shadow: 1px 1px #000;
}

.tail-dori {
  left: 7px;
}

.tail-player {
  right: 7px;
}

.tail-your-turn {
  color: #ffe566;
  animation: tail-pulse 0.35s steps(2) infinite;
}

@keyframes tail-pulse {
  50% { transform: scale(1.08); }
}

#customizer-canvas {
  display: block;
  width: min(420px, 76vw);
  height: auto;
  margin: 0 auto 12px;
  border: 3px solid #ffe566;
  background: #bde9ff;
  cursor: crosshair;
  touch-action: none;
}

.custom-label {
  margin-top: 8px;
  color: #b7e4c7;
}

.custom-tools {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 5px 0;
}

#overlay-content .custom-tools button {
  min-width: 42px;
  margin: 0;
  padding: 8px;
}

#overlay-content .custom-colors button,
#overlay-content [data-ink] {
  width: 34px;
  min-width: 34px;
  height: 34px;
  border: 3px solid #d8ffc2;
  background: var(--swatch);
}

#overlay-content .custom-tools button.selected {
  outline: 3px solid #ffe566;
  transform: translateY(-2px);
}

#controls-help {
  position: absolute;
  bottom: -36px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 6px;
  color: #74c69d;
}

#controls-help kbd {
  background: #1b4332;
  padding: 2px 4px;
  border-radius: 2px;
  border: 1px solid #40916c;
}
