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

html, body {
  overflow: hidden;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #1a1a2e;
  color: #fff;
}

/* -- Game Picker -- */
#picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  overflow-y: auto;
  height: 100vh;
}

#picker h1 {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  letter-spacing: -1px;
}

#picker p {
  font-size: 1.2rem;
  color: #aaa;
  margin-bottom: 3rem;
}

.games {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.card {
  width: 280px;
  height: 340px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  color: #fff;
  padding: 2rem;
  text-align: center;
}

.card:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

.card:active { transform: scale(0.98); }

.card .icon { font-size: 5rem; margin-bottom: 1rem; }
.card .name { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.card .sub { font-size: 1rem; opacity: 0.85; }

.card.oregon      { background: linear-gradient(135deg, #2d6a4f, #40916c); }
.card.number      { background: linear-gradient(135deg, #e63946, #f4845f); }
.card.word        { background: linear-gradient(135deg, #457b9d, #a8dadc); }
.card.carmen      { background: linear-gradient(135deg, #c0392b, #e74c3c); }
.card.lemonade    { background: linear-gradient(135deg, #f39c12, #f1c40f); }
.card.mathblaster { background: linear-gradient(135deg, #2c3e50, #3498db); }
.card.reader      { background: linear-gradient(135deg, #8e44ad, #9b59b6); }
.card.keen        { background: linear-gradient(135deg, #16a085, #1abc9c); }
.card.doom        { background: linear-gradient(135deg, #8b0000, #cc0000); }
.card.mk          { background: linear-gradient(135deg, #1a1a1a, #4a0e0e); }

/* -- Recently Played Section -- */
.recent-section {
  width: 100%;
  max-width: 900px;
  margin-bottom: 1.5rem;
}

.recent-title {
  font-size: 1.1rem;
  color: #aaa;
  margin-bottom: 0.75rem;
  text-align: center;
}

.recent-games {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.card.card-small {
  width: 200px;
  height: 160px;
  padding: 1rem;
  border-radius: 14px;
}

.card.card-small .icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.card.card-small .name {
  font-size: 1rem;
}

/* -- Category Filter Bar -- */
.category-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.category-tab {
  background: #2a2a3e;
  color: #aaa;
  border: none;
  padding: 0.5rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.category-tab:hover {
  background: #3a3a5e;
  color: #fff;
}

.category-tab.active {
  background: #4caf50;
  color: #fff;
}

/* -- Game Player -- */
#player {
  display: none;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  background: #000;
  position: relative;
}

#player.active { display: flex; }
#picker.hidden { display: none; }

.toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: #111;
  flex-shrink: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 50;
}

.toolbar.toolbar-hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.toolbar button {
  background: #333;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar button:hover { background: #555; }

.toolbar .speaker-icon {
  font-size: 1.1rem;
  line-height: 1;
}

#dos-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Hide js-dos built-in UI in kiosk mode */
#dos-container .emulator-mouse-overlay { cursor: default; }

/* -- How to Play Overlay -- */
.help-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeInOverlay 0.3s ease;
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.help-card {
  background: #fff;
  color: #222;
  border-radius: 20px;
  padding: 2.5rem 2.5rem 2rem;
  max-width: 460px;
  width: 90%;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.help-card h2 {
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
}

.help-card .help-subtitle {
  font-size: 1rem;
  color: #888;
  margin-bottom: 1.2rem;
}

.help-card ul {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  text-align: left;
}

.help-card ul li {
  font-size: 1.15rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.help-card ul li:last-child {
  border-bottom: none;
}

.help-card ul li::before {
  content: '\27A1';
  font-size: 1rem;
  flex-shrink: 0;
}

.help-card .help-btn {
  background: linear-gradient(135deg, #4caf50, #66bb6a);
  color: #fff;
  border: none;
  padding: 0.9rem 2.2rem;
  font-size: 1.2rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(76, 175, 80, 0.4);
}

.help-card .help-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

.help-card .help-btn:active {
  transform: scale(0.97);
}

/* -- Keyboard Helper Panel -- */
.keyboard-helper {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.85);
  color: #ddd;
  padding: 1rem 1.2rem;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.6;
  z-index: 95;
  max-width: 260px;
  animation: fadeInOverlay 0.2s ease;
}

.keyboard-helper-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.keyboard-helper-close {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.keyboard-helper-close:hover {
  color: #fff;
}

.keyboard-helper ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.keyboard-helper ul li {
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.keyboard-helper ul li:last-child {
  border-bottom: none;
}

/* -- Toast Notification -- */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #333;
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-fade-out {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
}

/* -- Saved Badge -- */
.card {
  position: relative;
}

.saved-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: #2d6a4f;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* -- Picker Footer / About Link -- */
.picker-footer {
  margin-top: 2rem;
  padding-bottom: 2rem;
}

.about-link {
  background: none;
  border: none;
  color: #666;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

.about-link:hover {
  color: #aaa;
}

/* -- About/Share Overlay -- */
.about-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  animation: fadeInOverlay 0.3s ease;
}

.about-card {
  background: #fff;
  color: #222;
  border-radius: 20px;
  padding: 2.5rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  position: relative;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: popIn 0.3s ease;
}

.about-card h2 {
  font-size: 1.8rem;
  margin-bottom: 0.75rem;
}

.about-card p {
  font-size: 1rem;
  color: #555;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.about-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #999;
  cursor: pointer;
  line-height: 1;
}

.about-close:hover {
  color: #333;
}

.about-copy-btn {
  background: linear-gradient(135deg, #4caf50, #66bb6a);
  color: #fff;
  border: none;
  padding: 0.75rem 1.8rem;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(76, 175, 80, 0.4);
}

.about-copy-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

.about-copy-btn:active {
  transform: scale(0.97);
}

/* -- Name Prompt Overlay -- */
.name-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeInOverlay 0.3s ease;
}

.name-card {
  background: #fff;
  color: #222;
  border-radius: 20px;
  padding: 2.5rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: popIn 0.3s ease;
}

.name-card h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.name-card p {
  font-size: 1.1rem;
  color: #666;
  margin-bottom: 1.5rem;
}

.name-input {
  width: 100%;
  padding: 0.9rem 1rem;
  font-size: 1.2rem;
  border: 2px solid #ddd;
  border-radius: 12px;
  outline: none;
  text-align: center;
  font-family: inherit;
  margin-bottom: 1.2rem;
  transition: border-color 0.2s;
}

.name-input:focus {
  border-color: #4caf50;
}

.name-btn {
  background: linear-gradient(135deg, #4caf50, #66bb6a);
  color: #fff;
  border: none;
  padding: 0.9rem 2.2rem;
  font-size: 1.2rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(76, 175, 80, 0.4);
}

.name-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

.name-btn:active {
  transform: scale(0.97);
}

/* -- Loading Screen -- */
.loading-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  transition: opacity 0.4s ease;
}

.loading-screen.loading-fade-out {
  opacity: 0;
}

.loading-content {
  text-align: center;
  max-width: 480px;
  width: 90%;
  padding: 2rem;
}

.loading-title {
  font-family: 'Courier New', Courier, monospace;
  font-size: 2.2rem;
  font-weight: 700;
  color: #33ff33;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  text-shadow: 0 0 10px rgba(51, 255, 51, 0.5);
}

.loading-dots {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.3rem;
  color: #ffb000;
  margin-bottom: 1.8rem;
  letter-spacing: 2px;
}

.loading-dots .dot {
  animation: dotBlink 1.4s infinite steps(1);
}

.loading-dots .dot-1 { animation-delay: 0s; }
.loading-dots .dot-2 { animation-delay: 0.3s; }
.loading-dots .dot-3 { animation-delay: 0.6s; }

@keyframes dotBlink {
  0%, 50% { opacity: 0; }
  51%, 100% { opacity: 1; }
}

.loading-bar {
  width: 100%;
  height: 12px;
  background: #1a1a1a;
  border-radius: 6px;
  border: 1px solid #333;
  overflow: hidden;
  margin-bottom: 2rem;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #33ff33, #66ff66);
  border-radius: 6px;
  animation: loadingProgress 5s ease-out forwards;
  box-shadow: 0 0 8px rgba(51, 255, 51, 0.4);
}

@keyframes loadingProgress {
  0%   { width: 0%; }
  20%  { width: 25%; }
  50%  { width: 55%; }
  80%  { width: 78%; }
  100% { width: 90%; }
}

.loading-fact {
  animation: factFadeIn 1s ease 0.5s both;
}

@keyframes factFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.loading-fact-label {
  display: block;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  color: #ffb000;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}

.loading-fact-text {
  display: block;
  font-style: italic;
  font-size: 1.05rem;
  color: #aaa;
  line-height: 1.6;
  border-left: 3px solid #33ff33;
  padding-left: 1rem;
  text-align: left;
}
