html, body {
  touch-action: manipulation;
}

body.modal-open {
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed;
  width: 100%;
  height: 100%;
  -webkit-overflow-scrolling: auto !important;
  touch-action: none;
}

body {
  margin: 0;
  background: linear-gradient(to bottom right, #111, #333);
  font-family: 'Press Start 2P', monospace;
  color: #fff;
  text-align: center;
}

.title {
  padding: 30px 20px 10px;
  font-size: 1.2rem;
  color: #00ffff;
  text-shadow: 0 0 8px #ff0, 0 0 20px #f0f;
}




.tab-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  margin: 10px 0 20px;
  padding: 10px;
  background: #111;
  border: 2px solid #0ff;
  border-radius: 12px;
  box-shadow: 0 0 12px #0ff;
}

.tab-link {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  color: #0ff;
  background: #000;
  padding: 10px 14px;
  text-decoration: none;
  border: 2px solid #0ff;
  border-radius: 8px;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 0 5px #0ff50;
}

.tab-link:hover,
.tab-link:focus {
  background: #0ff;
  color: #000;
  transform: scale(1.05);
  box-shadow: 0 0 10px #0ff;
}

.tab-link.active {
  background: #0ff;
  color: #000;
  pointer-events: none;
}

.star {
  font-size: 1.4rem;
  color: #888;
  cursor: pointer;
  margin-right: 10px;
  display: inline-block;
  transition: color 0.2s, transform 0.2s;
}

.star:hover {
  color: #ff0;
  transform: scale(1.2);
}

.star.favorited {
  color: #ff0;
}


.game-title a {
  color: #0ff;
  text-decoration: none;
}

.game-title a:hover {
  text-decoration: underline;
}



.game-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 20px;
  max-width: 1000px;
  margin: auto;
  transition: all 0.2s ease-in-out;
}


.game-tile {
  background: #222;
  border: 2px solid #555;
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.3s;
  text-decoration: none;
  color: white;
  box-shadow: 0 0 10px #000;
  width: 160px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.game-tile:hover {
  transform: scale(1.05);
  border-color: #0ff;
  box-shadow: 0 0 15px #0ff;
}

.game-tile img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.game-title {
  padding: 12px 6px;
  font-size: 0.75rem;
  background: #111;
  border-top: 1px solid #444;
}

/* Modal Overlay */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000d;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal.hidden {
  display: none;
}

.modal-content {
  position: fixed;
  width: 100vw;
  height: 100vh;
  background: black;
  display: flex;
  flex-direction: column;
  justify-content: center;
}


.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 24px;
  background: #222;
  color: white;
  border: 1px solid white;
  border-radius: 6px;
  z-index: 1001;
  padding: 4px 10px;
  cursor: pointer;
}

.dosbox-container {
  position: absolute;
  inset: 0;
  background: black;
  display: flex;
  justify-content: center;
  align-items: center;
}

.dosbox-container canvas {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  image-rendering: pixelated;
}

.keyboard-numpad {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: #111;
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 1002;
}

.keyboard-numpad .keyboard-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}



/* Controls Layout */

.controls-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.controls-container > div > .btn {
  pointer-events: auto;
}


.controls-left,
.controls-right {
  display: grid;
  gap: 8px;
  pointer-events: none; /* disables the grid itself */
}

.controls-left {
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(4, 60px);
}

.controls-right {
  grid-template-columns: repeat(3, 60px);
  grid-auto-rows: 60px;
}

/* Button Appearance */

.controls-left .btn,
.controls-right .btn {
  pointer-events: auto; /* only buttons receive interaction */
}

.btn {
  width: 60px;
  height: 60px;
  font-size: 20px;
  font-family: 'Press Start 2P', monospace;
  background: #222;
  color: white;
  border: 1px solid white;
  border-radius: 8px;
  transition: background 0.1s, transform 0.05s;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.btn:hover {
  background: #444;
}

.btn:active {
  background: #666;
  transform: scale(0.95);
}

/* Login View */

form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  padding: 30px;
}

form label {
  color: #0f0;
  font-size: 0.8rem;
}

input[type="password"] {
  font-size: 1.4rem;
  padding: 10px;
  width: 220px;
  text-align: center;
  letter-spacing: 10px;
  background: #111;
  color: #0f0;
  border: 2px solid #0f0;
  font-family: 'Press Start 2P', monospace;
}

button[type="submit"] {
  font-size: 1rem;
  padding: 12px 20px;
  background: #0f0;
  color: black;
  border: none;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
}

button[type="submit"]:hover {
  background: #8f8;
}

.error {
  color: #f00;
  font-size: 0.75rem;
}

/* Disclaimer + Logout */

p {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
}

a {
  color: #0ff;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* On-screen Keyboard */

.keyboard-wrapper {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 1001;
  overflow: visible;
}

/* Always clickable */
.keyboard-wrapper .keyboard-toggle {
  pointer-events: auto;
  font-size: 1.8rem;
  background: transparent;
  border: none;
  color: #0ff;
  padding: 4px;
  margin: 0;
  z-index: 1002;
}

/* Default state — bottom center */
.keyboard-wrapper .keyboard-toggle {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

/* When keyboard is visible — top-left inside keyboard */
.keyboard:not(.hidden) ~ .keyboard-toggle {
  top: 0;
  left: 0;
  bottom: auto;
  transform: none;
}



.keyboard,
.keyboard-toggle {
  pointer-events: auto;
}

.keyboard-toggle {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;      /* ...except this one button is clickable */
  font-size: 1.8rem;
  background: transparent;
  border: none;
  color: #0ff;
  padding: 4px;
  margin: 0;
  z-index: 1002;
}

.keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: #111;
}

.keyboard.hidden {
  display: none;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

.keyboard .btn {
  min-width: 40px;
  height: 40px;
  font-size: 1rem;
  padding: 0;
  line-height: 1;
}
