/* shared-game.css — Common styles for all Neon Parlor game pages */

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

/* ── Accessibility: screen-reader-only utility ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ── Accessibility: focus-visible for keyboard navigation ── */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Accessibility: reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

/* ── Game header ── */

.game-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 16px;
  width: 100%;
  max-width: 1400px;
}
.game-header a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.game-header img { width: 28px; height: 28px; }
.game-header h1, .game-header .logo-text {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0;
}
.game-header .logo-lobby { color: var(--text); font-weight: 700; }
.game-header .logo-room {
  color: var(--accent);
  font-weight: 600;
  text-shadow: 0 0 10px var(--accent-glow);
}
.game-header .header-sep { color: var(--text-subtle); font-size: var(--text-md); }
.game-header .header-room-info {
  color: var(--text-muted);
  font-size: var(--text-base);
  font-weight: 400;
}
.game-header .header-room-info .room-name { color: var(--accent); }
.game-header .header-room-info .table-num { color: var(--text-subtle); }

/* ── Game container ── */

#game-container {
  width: 100%;
  max-width: 1400px;
  padding: 0 8px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Game menu (kebab menu inside score/turn bar) ── */

#game-menu-wrap {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}
#game-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 2px 6px;
  line-height: 1;
  opacity: 0.6;
  color: var(--near-white);
}
#game-menu-btn:hover { opacity: 1; }
#game-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-width: 120px;
  z-index: 100;
  overflow: hidden;
}
#game-menu.hidden { display: none; }
#game-menu button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px 14px;
  font-size: var(--text-base);
  text-align: left;
  cursor: pointer;
}
#game-menu button:hover { background: var(--accent-ghost); color: var(--near-white); }
#menu-resign { color: var(--error); }
#menu-resign:hover { background: var(--error-bg); color: var(--error); }

/* ── Game layout ── */

#game-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#game-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin: 4px 0;
}

#canvas-wrapper {
  flex: none;
  position: relative;
}

/* ── Side-chat layout ── */

#game-layout.side-chat {
  display: flex;
  flex-direction: row;
  gap: 8px;
  justify-content: center;
  align-items: stretch;
}
#game-layout.side-chat #game-row {
  flex: 0 0 auto;
}
#game-layout.side-chat #chat-box {
  flex: 0 0 300px;
  max-width: none;
  width: auto;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
#game-layout.side-chat #chat-messages {
  flex: 1;
  height: auto;
  min-height: 0;
  overflow-y: auto;
}
#game-layout.side-chat #chat-input-row {
  flex-shrink: 0;
}

/* ── Chat box ── */

#chat-box {
  display: none;
  width: 100%;
  max-width: 1400px;
  margin: 4px auto 4px;
  background: var(--overlay-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
#chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
#chat-box.visible {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 10px;
  font-size: var(--text-sm);
  line-height: 1.5;
  scrollbar-width: thin;
  scrollbar-color: var(--text-subtle) transparent;
}
#chat-messages::-webkit-scrollbar { width: 5px; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--text-subtle); border-radius: 3px; }
#chat-messages .chat-msg { margin-bottom: 2px; }
#chat-messages .chat-time {
  color: var(--text-subtle);
  font-size: var(--text-xs);
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}
#chat-messages .chat-system { color: var(--text-muted); font-style: italic; }
#chat-messages .chat-system.highlight { color: var(--accent); font-style: normal; font-weight: 600; }
#chat-messages .chat-sender { color: var(--accent); font-weight: 600; margin-right: 4px; }
#chat-messages .chat-text { color: var(--text-muted); }
#chat-input-row {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 4px 6px;
  display: flex;
  gap: 4px;
  align-items: center;
}
#chat-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--near-white);
  font-size: var(--text-sm);
  padding: 5px 8px;
  outline: none;
  box-sizing: border-box;
}
#chat-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
#chat-input::placeholder { color: var(--text-subtle); }
#chat-input:focus { border-color: var(--accent-glow-subtle); box-shadow: 0 0 6px var(--accent-glow-subtle); }
#chat-send-btn {
  flex-shrink: 0;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--near-black);
  font-size: var(--text-md);
  padding: 4px 10px;
  cursor: pointer;
  line-height: 1;
}
#chat-send-btn:active { background: var(--accent-hover); }

/* ── Spectator bar & sit-down button ── */

#spectator-bar { display: none; text-align: center; margin-bottom: 4px; }
.sit-down-btn {
  background: var(--gradient-cta);
  color: var(--near-black);
  border: none;
  border-radius: var(--radius-md);
  padding: 5px 16px;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  margin-left: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: box-shadow 0.2s;
  box-shadow: var(--gradient-cta-shadow);
}
.sit-down-btn:hover { box-shadow: var(--gradient-cta-shadow-hover); }

/* ── Landscape back-to-lobby link (visible when header is hidden) ── */
.landscape-back-link {
  display: none;
}
@media (max-height: 500px) and (orientation: landscape) {
  .landscape-back-link {
    display: block;
    position: fixed;
    top: 4px;
    left: 8px;
    z-index: 100;
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--text-xs);
    padding: 2px 8px;
    background: var(--overlay);
    border-radius: var(--radius-sm);
  }
  .landscape-back-link:hover { color: var(--near-white); }
}

/* ── Shared mobile header breakpoint ── */

@media (max-width: 600px) {
  .game-header { padding: 4px 10px; gap: 6px; }
  .game-header h1, .game-header .logo-text { font-size: 1.1rem; }
  .game-header img { width: 22px; height: 22px; }
  .game-header .header-room-info { font-size: var(--text-xs); }
}

/* ── Private room — waiting-for-friend bar ── */

.pr-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--accent-ghost-border);
  border-radius: var(--radius-lg);
  margin: 6px 0 2px;
  flex-shrink: 0;
  animation: prSlideIn 0.3s ease;
}
@keyframes prSlideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.pr-label {
  color: var(--accent);
  font-size: var(--text-base);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.pr-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}
.pr-link-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--text-sm);
  padding: 6px 10px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: text;
}
.pr-link-input:focus {
  outline: none;
  border-color: var(--accent-glow-subtle);
  color: var(--near-white);
}
.pr-link-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.pr-copy-btn {
  background: var(--gradient-cta);
  color: var(--near-black);
  border: none;
  border-radius: var(--radius-md);
  padding: 6px 16px;
  font-weight: 700;
  font-size: var(--text-sm);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  flex-shrink: 0;
  transition: box-shadow 0.15s;
}
.pr-copy-btn:hover { box-shadow: var(--gradient-cta-shadow-hover); }
.pr-copy-btn.copied { background: var(--success); }

.pr-cancel-btn {
  background: transparent;
  color: var(--text-subtle);
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}
.pr-cancel-btn:hover { color: var(--near-white); }

@media (max-width: 600px) {
  .pr-bar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .pr-label { font-size: var(--text-sm); }
  .pr-sep { display: none; }
  .pr-link-input { flex-basis: 100%; order: 10; font-size: var(--text-xs); }
  .pr-copy-btn { margin-left: auto; padding: 6px 14px; }
}

/* ── Spectator bar inline style replacements ── */
.spectator-back-link {
  color: var(--text-subtle);
  font-size: var(--text-sm);
  text-decoration: none;
}
.spectator-label {
  color: var(--text-subtle);
  font-size: var(--text-xs);
  margin-left: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── Pool turn bar (shared between game.html & play-pool) ── */

#turn-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--overlay);
  border-radius: var(--radius-lg);
  padding: 6px 16px;
  margin: 4px 0;
  min-height: 32px;
  font-size: var(--text-base);
  position: relative;
}
#turn-bar .player-name {
  color: var(--text-muted);
  font-size: var(--text-base);
  white-space: nowrap;
}
#turn-bar .player-name.active {
  color: var(--accent);
  font-weight: bold;
  text-shadow: 0 0 8px var(--accent-glow-subtle);
}
#turn-bar .player-rating {
  opacity: 0.7;
  font-size: var(--text-xs);
}
#turn-bar .group-icon {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 2px;
}
#turn-bar .group-icon.solid {
  background: #f5c842;
}
#turn-bar .group-icon.stripe {
  background: linear-gradient(135deg, #f5c842 40%, var(--bg) 40%, var(--bg) 60%, #f5c842 60%);
}
#turn-bar .vs {
  color: var(--near-white);
  font-weight: bold;
  font-size: var(--text-md);
}
#turn-bar .foul-indicator {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  background: var(--error-bg);
  color: var(--error);
  font-weight: 600;
  font-size: var(--text-xs);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 3px 10px;
  border-radius: 10px;
  border: 1px solid var(--error);
}
#turn-bar .foul-indicator.visible {
  display: inline-block;
  animation: badge-pop 0.4s ease-out;
}
#turn-bar .foul-indicator.hint {
  background: var(--accent-ghost);
  color: var(--text-muted);
  border-color: var(--border);
  animation: none;
}
@keyframes badge-pop {
  0% { opacity: 0; transform: translateY(-50%) scale(0.8); }
  50% { transform: translateY(-50%) scale(1.05); }
  100% { opacity: 1; transform: translateY(-50%) scale(1); }
}

/* ── Pool controls (shared between game.html & play-pool) ── */

#ball-tray {
  display: block;
  width: 100%;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

#sidebar {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 56px;
  flex-shrink: 0;
}
#sidebar.visible { display: flex; }
#sidebar canvas { display: block; }
#sidebar label {
  color: var(--text-subtle);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: -8px;
}

#controls-row {
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: var(--overlay-subtle);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
#controls-row.visible { display: flex; }
#controls-row .power-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
#controls-row .power-wrap label {
  color: var(--text-subtle);
  font-size: 7px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#controls-row #power-canvas-h {
  width: 100%;
  display: block;
}
#controls-row .english-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
#controls-row .english-wrap label {
  color: var(--text-subtle);
  font-size: 7px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#controls-row #english-canvas-h {
  width: 56px;
  height: 56px;
  display: block;
  flex-shrink: 0;
}

/* ── Air hockey score bar (shared between airhockey.html & air-hockey) ── */

#score-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--overlay);
  border-radius: var(--radius-lg);
  padding: 8px 20px;
  margin: 4px 0;
  min-height: 38px;
  font-size: var(--text-md);
  position: relative;
}
#score-bar .player-name {
  color: var(--text-muted);
  font-size: var(--text-md);
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
#score-bar .player-name.me {
  color: var(--accent);
  font-weight: bold;
  text-shadow: 0 0 8px var(--accent-glow-subtle);
}
.score-rating {
  opacity: 0.5;
  font-size: var(--text-xs);
  font-weight: 400;
}
#score-bar .score {
  font-size: 28px;
  font-weight: 800;
  color: var(--near-white);
  min-width: 24px;
  text-align: center;
}
#score-bar .score-sep {
  color: var(--text-subtle);
  font-size: 20px;
  font-weight: 300;
}

@media (max-width: 600px) {
  #score-bar { font-size: var(--text-sm); padding: 6px 12px; }
  #score-bar .score { font-size: 22px; }
  #turn-bar { font-size: var(--text-sm); padding: 4px 10px; gap: 8px; }
}
