/* ═══════════════════════════════════════════════════
   TCG Kiosk — Waiting Screen
   OLED-first dark theme. Touch-optimized. 60fps.
   ═══════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────── */
:root {
  --bg:          #000000;
  --bg-surface:  #0d0d0d;
  --bg-card:     #141414;
  --bg-elevated: #1c1c1c;

  --accent-green: #4a9afc;
  --accent-green-dim: #3a82e0;
  --accent-green-glow: rgba(74, 154, 252, 0.25);

  --accent-blue:  #40c4ff;
  --accent-amber: #ffab40;
  --accent-red:   #ff5252;

  --text-primary:   #ffffff;
  --text-secondary: rgba(255,255,255,0.6);
  --text-muted:     rgba(255,255,255,0.35);

  --border: rgba(255,255,255,0.08);

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 36px;

  --shadow-glow-green: 0 0 40px rgba(74, 154, 252, 0.3), 0 0 80px rgba(74, 154, 252, 0.1);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.6);

  --font-mono: 'Courier New', 'Lucida Console', 'SF Mono', monospace;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ── Screen base ────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* ── Top bar ────────────────────────────────────────── */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 20px 20px 0;
  z-index: 10;
  pointer-events: none;
}

/* ── Game logo ──────────────────────────────────────── */
.game-logo {
  font-size: 36px;
  line-height: 1;
  filter: drop-shadow(0 0 8px currentColor);
  transition: all 0.3s ease;
}

.game-logo[data-game="mtg"]::before      { content: "⚔️"; }
.game-logo[data-game="pokemon"]::before  { content: "⚡"; color: #ffd700; }
.game-logo[data-game="lorcana"]::before  { content: "✨"; color: #a78bfa; }
.game-logo[data-game="onepiece"]::before { content: "☠️"; }
.game-logo[data-game="custom"]::before   { content: "🃏"; }
.game-logo:not([data-game])::before,
.game-logo[data-game=""]::before         { content: "🎴"; }

/* ── Table badge ────────────────────────────────────── */
.table-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  min-width: 64px;
}

.table-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.table-num {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--accent-blue);
  font-family: var(--font-mono);
}

/* ── Clock ──────────────────────────────────────────── */
.clock-wrap {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 12px;
}

/* ── Landscape split layout ─────────────────────────── */
.landscape-split {
  flex: 1 1 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  gap: 24px;
  padding: 0 32px;
  overflow: hidden;
}

.split-left {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.split-left .barcode-wrap {
  padding: 0;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.split-left .barcode-img {
  max-height: 80vh;
  max-width: 40vw;
}

.split-right {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-width: 0;
}

.split-right .brand-title {
  font-size: clamp(32px, 8vw, 56px);
}

.split-right .event-name {
  padding: 0;
}

.split-right .checkin-area {
  padding: 8px 0;
  width: 100%;
  display: flex;
  justify-content: center;
}

.clock {
  font-family: var(--font-mono);
  font-size: clamp(72px, 22vw, 120px);
  font-weight: 100;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-shadow: 0 0 30px rgba(255,255,255,0.15);
  line-height: 1;
  transition: opacity 0.05s;
}

.brand-title {
  font-size: clamp(40px, 12vw, 64px);
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-shadow: 0 0 40px rgba(255,255,255,0.1);
  line-height: 1;
}

/* Tick animation — subtle brightness pulse on second change */
@keyframes tick {
  0%   { opacity: 1; }
  5%   { opacity: 0.85; }
  15%  { opacity: 1; }
}

.clock.ticking {
  animation: tick 0.3s ease;
}

/* ── Event name ─────────────────────────────────────── */
.event-name {
  font-size: clamp(14px, 3.5vw, 18px);
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  padding: 6px 24px 0;
  max-width: 90%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Barcode area ───────────────────────────────────── */
.barcode-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px 24px;
  min-height: 0;
  position: relative;
}

.barcode-img {
  max-width: 88%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  display: none;
  animation: fadeInScale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.barcode-img.visible {
  display: block;
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

.barcode-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 14px;
  letter-spacing: 0.05em;
}

.barcode-icon {
  font-size: 64px;
  opacity: 0.3;
  line-height: 1;
}

.barcode-placeholder.hidden {
  display: none;
}

/* ── Check In button ────────────────────────────────── */
.checkin-area {
  flex-shrink: 0;
  width: 100%;
  padding: 0 28px 40px;
  display: flex;
  justify-content: center;
}

.btn-checkin {
  width: 100%;
  max-width: 420px;
  height: 72px;
  background: var(--accent-green);
  color: #fff;
  border: none;
  border-radius: var(--radius-xl);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: var(--shadow-glow-green);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-checkin::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.25) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.15s;
}

.btn-checkin:active::after {
  opacity: 1;
}

.btn-checkin:active {
  transform: scale(0.96);
  box-shadow: 0 0 20px rgba(0, 230, 118, 0.4);
  background: var(--accent-green-dim);
}

.btn-checkin.pressed {
  transform: scale(0.94);
  background: var(--accent-green-dim);
}

/* Ripple effect */
@keyframes ripple {
  from { width: 0; height: 0; opacity: 0.5; }
  to   { width: 400px; height: 400px; opacity: 0; }
}

.btn-checkin .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transform: translate(-50%, -50%);
  animation: ripple 0.6s linear;
  pointer-events: none;
}

.btn-icon {
  font-size: 24px;
  line-height: 1;
}

.btn-label {
  font-size: 22px;
}

/* ── Offline badge ──────────────────────────────────── */
.offline-badge {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 171, 64, 0.15);
  border: 1px solid rgba(255, 171, 64, 0.4);
  color: var(--accent-amber);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 5px 14px;
  border-radius: 20px;
  white-space: nowrap;
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════
   TABLE NUMBER ONLY SCREEN (One Piece mode)
   ══════════════════════════════════════════════════════ */

#screen-tableonly {
  justify-content: center;
  background: var(--bg);
}

.tableonly-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px;
}

.tableonly-logo {
  font-size: 72px;
  line-height: 1;
  margin-bottom: 16px;
}

.tableonly-logo[data-game="onepiece"]::before { content: "☠️"; }
.tableonly-logo[data-game="mtg"]::before      { content: "⚔️"; }
.tableonly-logo[data-game="pokemon"]::before  { content: "⚡"; }
.tableonly-logo[data-game="lorcana"]::before  { content: "✨"; }
.tableonly-logo[data-game="custom"]::before   { content: "🃏"; }

.tableonly-label {
  font-size: clamp(16px, 5vw, 24px);
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.tableonly-number {
  font-family: var(--font-mono);
  font-size: clamp(120px, 40vw, 200px);
  font-weight: 900;
  line-height: 0.9;
  color: var(--text-primary);
  text-shadow: 0 0 60px rgba(255,255,255,0.2);
  letter-spacing: -0.04em;
}

/* ══════════════════════════════════════════════════════
   SETTINGS OVERLAY
   ══════════════════════════════════════════════════════ */

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  padding: 0;
  animation: overlayIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-overlay.closing {
  animation: overlayOut 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

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

.settings-panel {
  width: 100%;
  max-width: 520px;
  background: var(--bg-card);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 0 0 env(safe-area-inset-bottom, 0);
  animation: panelSlideIn 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.settings-overlay.closing .settings-panel {
  animation: panelSlideOut 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes panelSlideIn {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes panelSlideOut {
  from { transform: translateY(0); }
  to   { transform: translateY(100%); }
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 0;
  margin-bottom: 20px;
}

.settings-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.settings-close {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  touch-action: manipulation;
}

.settings-close:active {
  background: var(--bg-surface);
}

.settings-body {
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: -4px;
}

.settings-input {
  width: 100%;
  height: 52px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 16px;
  font-family: var(--font-mono);
  padding: 0 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.settings-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(64, 196, 255, 0.15);
}

.settings-input::placeholder {
  color: var(--text-muted);
  font-size: 14px;
}

.settings-status {
  min-height: 20px;
  font-size: 12px;
  color: var(--accent-amber);
  text-align: center;
}

.settings-footer {
  padding: 20px 24px 28px;
}

.btn-settings-save {
  width: 100%;
  height: 56px;
  background: var(--accent-blue);
  color: #000;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  touch-action: manipulation;
}

.btn-settings-save:active {
  transform: scale(0.97);
  background: #29b6f6;
}

/* ── Settings hotzone (long-press trigger) ──────────── */
.settings-hotzone {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 72px;
  height: 72px;
  z-index: 900;
  /* invisible */
}

/* ══════════════════════════════════════════════════════
   UTILITY ANIMATIONS
   ══════════════════════════════════════════════════════ */

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

/* ── Safe area support ──────────────────────────────── */
@supports (padding: max(0px)) {
  .checkin-area {
    padding-bottom: max(40px, env(safe-area-inset-bottom, 40px));
  }
  .top-bar {
    padding-top: max(20px, env(safe-area-inset-top, 20px));
  }
}
