* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background: radial-gradient(circle at center, #1b263b 0%, #0d131f 100%);
  color: #e0e6ed;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Main Container */
.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 4px 6px;
}

/* Header Bar */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #00ffcc, #ffea00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 255, 204, 0.15);
  color: #00ffcc;
  border: 1px solid rgba(0, 255, 204, 0.3);
}

.controls-toolbar {
  display: flex;
  gap: 6px;
}

.btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e0e6ed;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.select-surface {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e0e6ed;
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
}

/* Screen Canvas Frame */
.canvas-container {
  position: relative;
  background: #000;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 1;
}

#gameCanvas {
  display: block;
}

/* Error overlay (only shown when an unhandled error occurs) */
.error-overlay {
  position: absolute;
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 100%;
  background: rgba(15, 23, 42, 0.97);
  z-index: 50;
  display: flex; 
  flex-direction: column;
  align-items: center; 
  justify-content: center;
  padding: 24px;
  display: none;
}

.error-overlay.active { 
  display: flex; 
}

.error-title {
  color: #f87171; 
  font-size: 18px; 
  font-weight: 700;
  font-family: 'Outfit', monospace;
  margin-bottom: 12px;
}

.error-message {
  color: #e2e8f0; 
  font-size: 12px;
  font-family: monospace;
  background: rgba(0, 0, 0, 0.4);
  padding: 12px; 
  border-radius: 6px;
  max-width: 90%; 
  max-height: 60%;
  overflow: auto; 
  word-break: break-all;
  white-space: pre-wrap;
  border: 1px solid rgba(248, 113, 113, 0.3);
}

/* Footer Keyboards Hints */
footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: #8c9ba5;
  flex-shrink: 0;
}

.key-tag {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 2px 5px;
  color: #fff;
  font-family: monospace;
  font-weight: 700;
}

/* Fullscreen Mode Optimization */
:fullscreen .game-wrapper {
  padding: 0;
  justify-content: center;
}

:fullscreen header {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(13, 19, 31, 0.85);
  padding: 4px 12px;
  border-radius: 8px;
  backdrop-filter: blur(8px);
  width: auto !important;
  max-width: 90vw;
}

:fullscreen footer {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(13, 19, 31, 0.85);
  padding: 4px 12px;
  border-radius: 8px;
  backdrop-filter: blur(8px);
  max-width: 95vw !important;
}

:fullscreen .canvas-container {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  box-shadow: none;
}
