:root {
  --bg-main: #0B0D13;
  --bg-card: #151822;
  --bg-card-hover: #1A1E2B;
  --bg-inner: #0E1017;
  --border-subtle: #242938;
  --border-focus: #FF5A36;
  --text-main: #F1F3F7;
  --text-muted: #949BAE;
  --text-dim: #646C82;

  /* Theme Accents inspired by screenshot */
  --coral: #FF5A36;
  --coral-hover: #FF441A;
  --coral-shadow: #C93310;
  --cyan: #06B6D4;
  --cyan-border: #0891B2;
  --purple: #8B5CF6;
  --purple-border: #7C3AED;
  --emerald: #10B981;
  --emerald-border: #059669;
  --amber: #F59E0B;
  --amber-border: #D97706;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(circle at 50% 0%, rgba(255, 90, 54, 0.05) 0%, transparent 60%);
}

/* Typography */
h1, h2, h3, h4 {
  color: var(--text-main);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

p {
  color: var(--text-muted);
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Layout Containers */
.container {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.container-wide {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.main-content {
  flex: 1;
  padding: 2rem 0 3.5rem;
}

/* Header & Navbar */
.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background-color: rgba(11, 13, 19, 0.95);
  position: sticky;
  top: 0;
  z-index: 40;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-tile-icon {
  width: 36px;
  height: 36px;
  background: #FFFFFF;
  color: #111319;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  box-shadow: 0 3px 0 #CBD5E1;
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* Scrabble-style Letter Tiles */
.tile-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.letter-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #FFFFFF;
  color: #111319;
  font-family: var(--font-mono);
  font-weight: 800;
  border-radius: 10px;
  box-shadow: 0 4px 0 #CBD5E1, 0 6px 12px rgba(0, 0, 0, 0.25);
  user-select: none;
  transition: transform 150ms ease-out, box-shadow 150ms ease-out;
}

.letter-tile.tile-lg {
  width: 58px;
  height: 64px;
  font-size: 2rem;
}

.letter-tile.tile-md {
  width: 44px;
  height: 48px;
  font-size: 1.5rem;
}

.letter-tile.tile-sm {
  width: 32px;
  height: 36px;
  font-size: 1.1rem;
  border-radius: 6px;
  box-shadow: 0 3px 0 #CBD5E1;
}

.letter-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #CBD5E1, 0 10px 16px rgba(0, 0, 0, 0.35);
}

.letter-tile.tile-ending {
  background: #FFF7ED;
  color: #EA580C;
  box-shadow: 0 4px 0 #FDBA74, 0 8px 16px rgba(234, 88, 12, 0.2);
}

.letter-tile.tile-success {
  background: #ECFDF5;
  color: #059669;
  box-shadow: 0 4px 0 #6EE7B7;
  animation: tile-pop 300ms ease-out;
}

@keyframes tile-pop {
  0% { transform: scale(0.9); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* 3D Coral Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1.25rem;
  font-size: 0.9375rem;
  font-weight: 700;
  text-decoration: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  outline: none;
  transition: background-color 150ms ease-out, transform 100ms ease-out, box-shadow 100ms ease-out;
  user-select: none;
}

.btn-coral {
  background-color: var(--coral);
  color: #FFFFFF;
  height: 46px;
  box-shadow: 0 4px 0 var(--coral-shadow), 0 6px 12px rgba(255, 90, 54, 0.25);
}

.btn-coral:hover {
  background-color: var(--coral-hover);
  transform: translateY(-1px);
  box-shadow: 0 5px 0 var(--coral-shadow), 0 8px 16px rgba(255, 90, 54, 0.35);
}

.btn-coral:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--coral-shadow);
}

.btn-secondary {
  background-color: #1F2432;
  color: var(--text-main);
  height: 42px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 3px 0 #141720;
}

.btn-secondary:hover {
  background-color: #262C3D;
  border-color: #384259;
}

.btn-secondary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #141720;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Themed Game Cards */
.game-card {
  background-color: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1.5rem;
  transition: transform 150ms ease-out, border-color 150ms ease-out;
}

.game-card.theme-coral {
  border-color: rgba(255, 90, 54, 0.4);
}
.game-card.theme-coral:hover {
  border-color: var(--coral);
  transform: translateY(-2px);
}

.game-card.theme-cyan {
  border-color: rgba(6, 182, 212, 0.35);
}
.game-card.theme-cyan:hover {
  border-color: var(--cyan);
  transform: translateY(-2px);
}

.game-card.theme-purple {
  border-color: rgba(139, 92, 246, 0.35);
}
.game-card.theme-purple:hover {
  border-color: var(--purple);
  transform: translateY(-2px);
}

.game-card.theme-emerald {
  border-color: rgba(16, 185, 129, 0.35);
}
.game-card.theme-emerald:hover {
  border-color: var(--emerald);
  transform: translateY(-2px);
}

.game-card.theme-amber {
  border-color: rgba(245, 158, 11, 0.35);
}
.game-card.theme-amber:hover {
  border-color: var(--amber);
  transform: translateY(-2px);
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input, .form-select {
  width: 100%;
  height: 44px;
  padding: 0 1rem;
  background-color: var(--bg-inner);
  border: 1.5px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.9375rem;
  font-family: inherit;
  outline: none;
  transition: border-color 150ms ease-out;
}

.form-input:focus, .form-select:focus {
  border-color: var(--coral);
}

.form-input.code-input {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  text-align: center;
  font-weight: 800;
}

.form-error {
  display: none;
  font-size: 0.8125rem;
  color: #F87171;
  margin-top: 0.375rem;
  font-weight: 500;
}

.form-error.active {
  display: block;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-inner);
  color: var(--text-muted);
}

.badge-coral {
  border-color: var(--coral);
  color: #FFA085;
}

.badge-emerald {
  border-color: var(--emerald);
  color: #34D399;
}

/* Room 2-Column Layout */
.room-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 960px) {
  .room-layout {
    grid-template-columns: 1fr;
  }
}

/* Room Header Bar */
.room-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background-color: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: 14px;
  margin-bottom: 1.5rem;
}

.room-code-badge {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: #FFFFFF;
  background-color: var(--bg-inner);
  border: 1px solid var(--border-subtle);
  padding: 0.25rem 0.85rem;
  border-radius: 8px;
}

/* BOMB STYLING & ANIMATIONS */
.bomb-arena {
  background-color: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.bomb-wrapper {
  position: relative;
  display: inline-block;
  margin-bottom: 1rem;
}

.bomb-svg {
  width: 140px;
  height: 140px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
  transition: transform 150ms ease-out;
}

.bomb-pulsing {
  animation: bomb-shake 250ms infinite alternate ease-in-out;
}

.bomb-spark {
  animation: spark-flash 150ms infinite alternate ease-in-out;
  transform-origin: center;
}

@keyframes bomb-shake {
  0% { transform: translate(-3px, -2px) rotate(-3deg) scale(1.05); }
  50% { transform: translate(3px, 2px) rotate(3deg) scale(1.08); }
  100% { transform: translate(-2px, 3px) rotate(-2deg) scale(1.05); }
}

@keyframes spark-flash {
  0% { opacity: 0.4; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1.4); }
}

.screen-shake {
  animation: screen-shake-kf 400ms ease-in-out;
}

@keyframes screen-shake-kf {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-8px, 6px); }
  40% { transform: translate(8px, -6px); }
  60% { transform: translate(-6px, -4px); }
  80% { transform: translate(6px, 4px); }
}

.bomb-timer-display {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 800;
  color: #FFFFFF;
  margin-top: 0.5rem;
  line-height: 1;
}

.bomb-timer-display.danger {
  color: #EF4444;
  animation: bomb-timer-blink 300ms infinite alternate;
}

@keyframes bomb-timer-blink {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

/* Ending Prompt Row */
.ending-prompt-container {
  margin: 1.25rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.ending-tiles-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Word Input for Bomb */
.word-submission-form {
  max-width: 520px;
  margin: 0 auto;
}

.word-input-large {
  height: 56px;
  font-size: 1.5rem;
  font-family: var(--font-mono);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  border-radius: 12px;
  border: 2px solid var(--border-subtle);
  background-color: var(--bg-inner);
}

.word-input-large:focus {
  border-color: var(--coral);
}

.word-input-large.input-error-shake {
  border-color: #EF4444;
  animation: word-shake 300ms ease-in-out;
}

@keyframes word-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* Hearts / Lives indicator */
.heart-icon {
  width: 20px;
  height: 20px;
  fill: #EF4444;
  filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.4));
  transition: transform 200ms ease-out, opacity 200ms ease-out;
}

.heart-icon.lost {
  fill: #374151;
  filter: none;
  opacity: 0.4;
}

/* Players Table in Lobby & Game */
.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background-color: var(--bg-inner);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.player-row.is-active-turn {
  border-color: var(--coral);
  background-color: #1A171D;
  box-shadow: 0 0 15px rgba(255, 90, 54, 0.15);
}

.player-row.is-eliminated {
  opacity: 0.4;
  background-color: #0B0D12;
}

/* Chat Panel */
.chat-panel {
  display: flex;
  flex-direction: column;
  height: 600px;
  max-height: calc(100vh - 160px);
  min-height: 440px;
  position: sticky;
  top: 5rem;
  background-color: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1.25rem;
}

@media (max-width: 960px) {
  .chat-panel {
    position: static;
    height: 400px;
  }
}

.chat-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
}

.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 0.375rem;
  margin-bottom: 0.75rem;
}

.chat-messages-container::-webkit-scrollbar {
  width: 5px;
}
.chat-messages-container::-webkit-scrollbar-track {
  background: var(--bg-inner);
}
.chat-messages-container::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 2px;
}

.chat-msg-row {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  background-color: var(--bg-inner);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.375rem 0.625rem;
}

.chat-msg-row.is-me-row {
  border-color: #384259;
  background-color: #131722;
}

.chat-msg-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.chat-sender-name {
  font-weight: 700;
  color: #60A5FA;
}

.chat-sender-name.is-me-sender {
  color: #34D399;
}

.chat-time {
  font-size: 0.6875rem;
  color: var(--text-dim);
}

.chat-body-text {
  font-size: 0.875rem;
  color: var(--text-main);
  word-break: break-word;
  line-height: 1.4;
}

.chat-system-notice {
  font-size: 0.75rem;
  color: var(--text-muted);
  background-color: var(--bg-inner);
  border: 1px solid var(--border-subtle);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  text-align: center;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.75rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-main);
  padding: 1.5rem 0;
  font-size: 0.8125rem;
  color: var(--text-dim);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}
