/* style.css — Green retro handheld puzzle device */

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

body {
  background: #0d0d0d;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Courier New', 'Monaco', monospace;
  color: #ddd;
  overflow: hidden;
  user-select: none;
}

/* ─── Device shell ──────────────────────────────────── */

.device {
  width: 420px;
  background: linear-gradient(145deg, #4caf50, #2e7d32);
  border-radius: 32px;
  padding: 18px 20px 22px;
  box-shadow:
    0 0 0 4px #1b5e20,
    0 8px 32px rgba(0,0,0,0.7),
    inset 0 2px 4px rgba(255,255,255,0.15);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Top bar ───────────────────────────────────────── */

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  font-size: 13px;
  font-weight: bold;
  color: #1b5e20;
}

.top-bar .badge {
  background: #1b5e20;
  color: #a5d6a7;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  letter-spacing: 1px;
}

/* ─── Screen ────────────────────────────────────────── */

.screen-bezel {
  background: #1a1d23;
  border-radius: 12px;
  padding: 6px;
  box-shadow:
    inset 0 3px 8px rgba(0,0,0,0.6),
    0 1px 0 rgba(255,255,255,0.08);
}

.screen {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

/* ─── Info strip ────────────────────────────────────── */

.info-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 6px;
  font-size: 11px;
  color: #a5d6a7;
}

.info-strip span { opacity: 0.85; }

/* ─── Action history ────────────────────────────────── */

.history-bar {
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 10px;
  color: #81c784;
  min-height: 20px;
  overflow-x: auto;
  white-space: nowrap;
}

/* ─── Controls ──────────────────────────────────────── */

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 2px 0;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.btn-group-label {
  font-size: 9px;
  text-transform: uppercase;
  color: #1b5e20;
  font-weight: bold;
  letter-spacing: 1px;
  text-align: center;
}

.btn-row {
  display: flex;
  gap: 4px;
}

button {
  flex: 1;
  padding: 8px 4px;
  font-family: inherit;
  font-size: 11px;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
  text-align: center;
  letter-spacing: 0.5px;
}

button:active:not(.disabled) {
  transform: scale(0.94);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.4) !important;
}

/* Rotate A */
.btn-rotate-a {
  background: linear-gradient(180deg, #ef5350, #c62828);
  color: #fff;
  box-shadow: 0 3px 0 #8e0000, 0 4px 8px rgba(0,0,0,0.3);
}
.btn-rotate-a:hover:not(.disabled) { background: linear-gradient(180deg, #f44336, #b71c1c); }

/* Rotate B */
.btn-rotate-b {
  background: linear-gradient(180deg, #ab47bc, #6a1b9a);
  color: #fff;
  box-shadow: 0 3px 0 #4a148c, 0 4px 8px rgba(0,0,0,0.3);
}
.btn-rotate-b:hover:not(.disabled) { background: linear-gradient(180deg, #9c27b0, #7b1fa2); }

/* Slide */
.btn-slide {
  background: linear-gradient(180deg, #42a5f5, #1565c0);
  color: #fff;
  box-shadow: 0 3px 0 #0d47a1, 0 4px 8px rgba(0,0,0,0.3);
}
.btn-slide:hover:not(.disabled) { background: linear-gradient(180deg, #2196f3, #1976d2); }

/* Utility */
.btn-util {
  background: linear-gradient(180deg, #78909c, #455a64);
  color: #fff;
  box-shadow: 0 3px 0 #263238, 0 4px 8px rgba(0,0,0,0.3);
}
.btn-util:hover:not(.disabled) { background: linear-gradient(180deg, #607d8b, #37474f); }

/* Next Level */
.btn-next {
  background: linear-gradient(180deg, #66bb6a, #2e7d32);
  color: #fff;
  box-shadow: 0 3px 0 #1b5e20, 0 4px 8px rgba(0,0,0,0.3);
}
.btn-next:hover:not(.disabled) { background: linear-gradient(180deg, #4caf50, #388e3c); }

/* Disabled state */
button.disabled, button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}

/* ─── Shake animation ───────────────────────────────── */

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-4px); }
  40%      { transform: translateX(4px); }
  60%      { transform: translateX(-3px); }
  80%      { transform: translateX(3px); }
}

.shake {
  animation: shake 0.35s ease;
}

/* ─── Keyboard hints ────────────────────────────────── */

.key-hint {
  font-size: 8px;
  opacity: 0.5;
  display: block;
  margin-top: 1px;
}

/* ─── Game selector ─────────────────────────────────── */

.game-select {
  background: #1b5e20;
  color: #a5d6a7;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-family: inherit;
  font-weight: bold;
  letter-spacing: 1px;
  border: none;
  cursor: pointer;
  outline: none;
}

/* ─── Yellow button ─────────────────────────────────── */

.btn-yellow {
  background: linear-gradient(180deg, #ffca28, #f57f17);
  color: #fff;
  box-shadow: 0 3px 0 #e65100, 0 4px 8px rgba(0,0,0,0.3);
}
.btn-yellow:hover:not(.disabled) { background: linear-gradient(180deg, #ffd54f, #ff8f00); }

/* ─── Win overlay ───────────────────────────────────── */

.win-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,0.55);
  font-size: 24px;
  font-weight: bold;
  color: #f1c40f;
  text-shadow: 0 0 20px rgba(241,196,15,0.8);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.win-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Responsive ────────────────────────────────────── */

@media (max-width: 460px) {
  .device { width: 98vw; padding: 12px 10px 14px; border-radius: 20px; }
  button { padding: 7px 2px; font-size: 10px; }
}

@media (min-height: 900px) and (min-width: 500px) {
  .device { width: 480px; }
}
