/* Reset */
html, body, h1, p {
  margin: 0;
  padding: 0;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  font-family: Arial, sans-serif;
  color: #222;
  line-height: 1.5;
}

body {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px;
}

a {
  color: #3473ee;
}

.controls {
  display: grid;
  grid-template-areas: ".    up   ."
                       "left down right";
  /* Limit the size of the controls by the viewport size. */
  width: 75vmin;
  height: 50vmin;
  margin: 10px auto;
}

#up { grid-area: up; }
#down { grid-area: down; }
#left { grid-area: left; }
#right { grid-area: right; }

.controls button {
  color: #888;
  font-size: 8vmin;
  background: none;
  border: 2px solid;
  margin: 2px;
  border-radius: 5vmin;
}

.controls button:focus {
  outline: none;
}

@media (min-width: 10cm) and (min-height: 10cm) {
  /* Avoid controls getting too big on larger touch devices. */
  .controls {
    position: absolute;
    width: 7.5cm;
    height: 5cm;
    bottom: 1.5cm;
    right: 1.5cm;
  }
  .controls button {
    font-size: 0.8cm;
    border-radius: 0.5cm;
  }
}

#url,
#max-score-grid {
  background: #8883;
  padding: 2px;
  border-radius: 3px;
}

/* Lobby Code Display During Gameplay */
.lobby-code-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #8883;
  border-radius: 3px;
  font-family: Arial, sans-serif;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.lobby-label {
  color: #666;
  font-weight: normal;
}

.game-lobby-code {
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: bold;
  color: #ff8c0b;
  letter-spacing: 1px;
}

.copy-btn {
  background: none;
  border: 1px solid #aaa;
  border-radius: 3px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #666;
  transition: all 0.2s;
}

.copy-btn:hover {
  background: #ff8c0b;
  color: #fff;
  border-color: #ff8c0b;
}

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

footer {
  margin-top: auto;
  font-size: 0.9rem;
}

.invisible {
  display: none !important;
}

.hidden {
  visibility: hidden;
}

:root.touch .no-touch-only,
:root:not(.touch) .touch-only {
  display: none;
}

.expand-btn,
.collapse-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: bold;
  cursor: pointer;
  width: 1rem;
}

.expand-btn,
.expandable {
  transition: transform, opacity;
  transition-duration: .4s;
}

.expandable {
  display: inline-block;
  position: relative;
  height: 1.5rem;
  transform: translateX(-100%);
  /* Clear body padding so it doesn't show on the left of the expand-btn */
  padding-right: 10px;
}

.expand-btn {
  position: absolute;
  right: 0;
  top: 0;
  transform: translateX(100%);
  opacity: 1;
}

.help-toggle {
  color: #0bc3ff;;
}

.high-score-toggle {
  color: #ff8c0b;
}

.collapse-btn {
  color: #aaa;
}

.expandable.expanded {
  height: auto;
  transform: none;
}

.expandable.expanded .expand-btn {
  opacity: 0;
}



@media (prefers-color-scheme: dark) {
  html {
    background: #222;
    color: #eee;
  }
}

/* Icon font styles copied from Fontello. */
@font-face {
  font-family: 'icons';
  src: url('icons.woff2?40046441') format('woff2');
  font-weight: normal;
  font-style: normal;
}
[class^="icon-"]:before, [class*=" icon-"]:before {
  font-family: "icons";
  font-style: normal;
  font-weight: normal;
  speak: none;
  display: inline-block;
  text-decoration: inherit;
  width: 1em;
  margin-right: .2em;
  text-align: center;
  /* For safety - reset parent styles, that can break glyph codes*/
  font-variant: normal;
  text-transform: none;
  /* Animation center compensation - margins should be symmetric */
  /* remove if not needed */
  margin-left: .2em;
  /* Font smoothing. That was taken from TWBS */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}



/* Global High Score Popup Notification Styles */
.popup-notification {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  z-index: 1000;
  transition: transform 0.4s ease-in-out;
}

.popup-notification.show {
  transform: translateX(-50%) translateY(0);
}

.popup-content {
  background: #fff;
  color: #222;
  border: 2px solid #ff8c0b;
  padding: 15px 20px;
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  text-align: center;
  position: relative;
  max-width: 90vw;
  font-family: Arial, sans-serif;
  animation: popupSlide 0.4s ease-in-out;
}

@keyframes popupSlide {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

.popup-title {
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 8px;
  color: #ff8c0b;
}

.popup-score {
  font-weight: normal;
  margin-bottom: 8px;
  color: #222;
}

.popup-grid {
  background: #8883;
  padding: 6px 8px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9rem;
  word-break: break-all;
  margin-bottom: 5px;
  color: #222;
}

.popup-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 1;
  transition: color 0.2s;
  font-weight: bold;
}

.popup-close:hover {
  color: #222;
}

@media (prefers-color-scheme: dark) {
  .popup-content {
    background: #222;
    color: #eee;
    border-color: #ff8c0b;
  }
  
  .popup-title {
    color: #ff8c0b;
  }
  
  .popup-score,
  .popup-grid {
    color: #eee;
  }
  
  .popup-close {
    color: #aaa;
  }
  
  .popup-close:hover {
    color: #eee;
  }
}

/* Lobby System Styles */
.lobby-interface {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.lobby-interface.show {
  display: flex;
}

.lobby-card {
  background: #fff;
  border: 2px solid #222;
  border-radius: 3px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  font-family: Arial, sans-serif;
}

.lobby-card h2 {
  margin: 0 0 20px 0;
  color: #222;
  font-size: 1.4rem;
}

.lobby-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lobby-btn {
  padding: 12px 20px;
  border: 2px solid;
  border-radius: 3px;
  background: none;
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: 1rem;
  transition: background 0.2s, color 0.2s;
}

.lobby-btn.primary {
  color: #ff8c0b;
  border-color: #ff8c0b;
}

.lobby-btn.primary:hover {
  background: #ff8c0b;
  color: #fff;
}

.lobby-btn.secondary {
  color: #888;
  border-color: #888;
}

.lobby-btn.secondary:hover {
  background: #888;
  color: #fff;
}

.lobby-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: none !important;
}

.lobby-form {
  margin-top: 20px;
}

.form-hidden {
  display: none !important;
}

.input-container {
  margin-bottom: 15px;
}

.lobby-form input {
  width: 100%;
  padding: 12px;
  border: 2px solid #888;
  border-radius: 3px;
  font-family: Arial, sans-serif;
  font-size: 1.2rem;
  text-align: center;
  letter-spacing: 2px;
  transition: border-color 0.2s;
}

.lobby-form input:focus {
  outline: none;
  border-color: #ff8c0b;
}

.lobby-form input.valid {
  border-color: #28a745;
}

.lobby-form input.invalid {
  border-color: #dc3545;
}

.validation-message {
  font-size: 0.9rem;
  margin-top: 5px;
  min-height: 1.2rem;
  text-align: center;
}

.validation-message.error {
  color: #dc3545;
}

.validation-message.success {
  color: #28a745;
}

.form-buttons {
  display: flex;
  gap: 10px;
}

.lobby-info {
  margin-top: 20px;
  text-align: left;
}

.lobby-info p {
  margin: 10px 0;
  color: #222;
}

.lobby-code {
  font-family: monospace;
  font-size: 1.5rem;
  color: #ff8c0b;
  font-weight: bold;
  letter-spacing: 2px;
}

.lobby-high-grid {
  background: #8883;
  padding: 8px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9rem;
  word-break: break-all;
  margin: 10px 0;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .lobby-card {
    background: #222;
    color: #eee;
    border-color: #eee;
  }
  
  .lobby-card h2 {
    color: #eee;
  }
  
  .lobby-info p {
    color: #eee;
  }
  
  .lobby-form input {
    background: #222;
    color: #eee;
    border-color: #888;
  }
  
  .lobby-form input:focus {
    border-color: #ff8c0b;
  }
  
  .lobby-form input.valid {
    border-color: #28a745;
  }
  
  .lobby-form input.invalid {
    border-color: #dc3545;
  }
  
  .validation-message.error {
    color: #ff6b6b;
  }
  
  .validation-message.success {
    color: #4caf50;
  }
  
  .lobby-label {
    color: #aaa;
  }
  
  .copy-btn {
    color: #aaa;
    border-color: #666;
  }
  
  .copy-btn:hover {
    background: #ff8c0b;
    color: #fff;
    border-color: #ff8c0b;
  }
}
