/*
 * ITTickets — flat, modular UI.
 * Left sidebar nav, white content area, subtle teal/green accent.
 * Cards are reserved for interactive panels (filters, forms, detail
 * widgets) — plain tables/lists stay un-boxed where possible.
 */

:root {
  --accent: #0B6E4F;
  --accent-dark: #095c40;
  --accent-light: #e6f4ee;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --border: #e2e6e4;
  --text: #1f2b28;
  --muted: #66756f;
  --danger: #c81e1e;
  --danger-light: #fde8e8;
  --success: #15803d;
  --success-light: #e6f9ec;
  --warning: #b45309;
  --warning-light: #fef3e2;
  --info: #1a56db;
  --info-light: #e8f0fe;
  --radius: 8px;
  --sidebar-w: 220px;
}

* {
  box-sizing: border-box;
}

/* display:flex/inline-flex rules must not override the HTML hidden attribute */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 400;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}

a {
  color: var(--accent-dark);
}

h1, h2, h3 {
  font-weight: 600;
  margin: 0;
}

p {
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
}

/* ---------------------------------------------------------------- shell */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 22px 20px;
  font-size: 1.1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.sidebar-brand-logo {
  display: block;
  width: 120px;
  height: auto;
  border-radius: 4px;
}

.sidebar-brand-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 0;
}

.sidebar-nav a {
  display: block;
  padding: 10px 20px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: var(--accent-light);
  color: var(--accent-dark);
}

.sidebar-nav a.active {
  background: var(--accent-light);
  border-left-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 600;
}

.sidebar-section {
  display: block;
  padding: 14px 20px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.sidebar-user strong {
  display: block;
  color: var(--text);
  font-size: 0.9rem;
}

.sidebar-user-role {
  display: block;
  text-transform: capitalize;
  margin-bottom: 8px;
}

.sidebar-user a.logout {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.sidebar-user a.logout:hover {
  text-decoration: underline;
}

.content {
  flex: 1;
  padding: 32px 40px;
  max-width: 1200px;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.content-header h1 {
  font-size: 1.5rem;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.card + .card {
  margin-top: 20px;
}

.card-title {
  font-size: 1rem;
  margin-bottom: 14px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 18px 20px;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-dark);
}

.stat-label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* --------------------------------------------------------------- forms */

label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 4px;
}

input, select, textarea {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

textarea {
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-inline {
  flex-direction: row;
  align-items: center;
}

.field-inline label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
  font-size: 0.88rem;
  color: var(--text);
}

.field-inline input[type="checkbox"] {
  width: auto;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.form-stacked .field {
  margin-bottom: 16px;
}

/* ----------------------------------------------------------- status slider */

.status-slider {
  display: inline-flex;
  align-items: stretch;
  margin: 0 0 16px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  gap: 2px;
}

.status-slider-opt {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.2;
}

.status-slider-opt:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
}

.status-slider-opt.is-active {
  background: var(--accent);
  color: #fff;
}

.status-slider-opt.is-active:hover {
  background: var(--accent-dark);
  color: #fff;
}

.status-slider-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4em;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.08);
}

.status-slider-opt.is-active .status-slider-count {
  background: rgba(255, 255, 255, 0.22);
}

form.filters.filters-top {
  margin-bottom: 12px;
}

form.filters .field-grow {
  flex: 1 1 220px;
  min-width: 200px;
}

form.filters .field-grow input {
  width: 100%;
}

/* ----------------------------------------------------------- ticket tabs */

.ticket-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.ticket-tab {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 18px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.ticket-tab:hover {
  color: var(--text);
}

.ticket-tab.is-active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}

.tickets-board.is-loading {
  opacity: 0.72;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

form.filters {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
}

form.filters .field {
  margin-bottom: 0;
  min-width: 160px;
}

form.filters .field:last-child {
  min-width: 0;
}

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
}

.btn:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn.btn-secondary:hover {
  background: var(--bg);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------- tables */

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

table.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.table tr:last-child td {
  border-bottom: none;
}

table.table tr:hover td {
  background: #fafbfa;
}

@keyframes ticket-unread-pulse {
  0%, 100% {
    background-color: rgba(11, 110, 79, 0.06);
    box-shadow: inset 3px 0 0 var(--accent);
  }
  50% {
    background-color: rgba(11, 110, 79, 0.16);
    box-shadow: inset 3px 0 0 var(--accent-dark);
  }
}

@keyframes ticket-unread-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.65; }
}

table.table tr.ticket-row.is-unread td {
  animation: ticket-unread-pulse 1.6s ease-in-out infinite;
}

table.table tr.ticket-row.is-unread .ticket-unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
  animation: ticket-unread-dot 1.6s ease-in-out infinite;
}

.status-slider-opt.has-unread .status-slider-count {
  animation: ticket-unread-pulse 1.6s ease-in-out infinite;
}

table.table a {
  text-decoration: none;
  font-weight: 500;
}

table.table a:hover {
  text-decoration: underline;
}

.pagination {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-status-open { background: var(--info-light); color: var(--info); }
.badge-status-in_progress { background: var(--accent-light); color: var(--accent-dark); }
.badge-status-waiting { background: var(--warning-light); color: var(--warning); }
.badge-status-resolved { background: var(--success-light); color: var(--success); }
.badge-status-closed { background: #eef0ef; color: #5b6b64; }

.badge-priority-low { background: #eef0ef; color: #5b6b64; }
.badge-priority-normal { background: var(--info-light); color: var(--info); }
.badge-priority-high { background: var(--warning-light); color: var(--warning); }
.badge-priority-urgent { background: var(--danger-light); color: var(--danger); }

.channel-tag {
  display: inline-block;
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent-dark);
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.channel-tag-in {
  background: var(--warning-light);
  color: var(--warning);
}

.channel-tag-out {
  background: var(--info-light);
  color: var(--info);
}

/* ---------------------------------------------------------------- attachments */

.attach-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.attach-heading {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.attach-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.attach-gallery-sm {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  margin-top: 10px;
}

.attach-thumb {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.attach-thumb img {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: cover;
  background: #f3f5f4;
}

.attach-gallery-sm .attach-thumb img {
  height: 88px;
}

.attach-thumb span {
  padding: 0 8px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-thumb:hover {
  border-color: var(--accent);
}

.attach-files {
  list-style: none;
  margin: 0;
  padding: 0;
}

.attach-files li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.attach-files li:last-child {
  border-bottom: none;
}

.attach-files a {
  font-weight: 500;
  word-break: break-all;
}

.comment-internal {
  background: #fafaf8;
  border-left: 3px solid var(--warning);
  padding-left: 12px;
  margin-left: -4px;
}

.comment-public {
  border-left: 3px solid var(--accent, #1f5c45);
  padding-left: 12px;
  margin-left: -4px;
}

.reply-mode {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 12px;
}

.reply-mode legend {
  padding: 0 4px;
}

.reply-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 4px;
  cursor: pointer;
}

.reply-option + .reply-option {
  border-top: 1px solid var(--border);
}

.reply-option input {
  margin-top: 4px;
}

.reply-option strong {
  display: block;
}

.reply-option small {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

/* ---------------------------------------------------------------- alerts */

.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #f8b4b4;
}

.alert-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid #a7e8bc;
}

/* ---------------------------------------------------------- ticket detail */

.ticket-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}

.ticket-main, .ticket-side {
  display: flex;
  flex-direction: column;
}

.ticket-main .card + .card,
.ticket-side .card + .card {
  margin-top: 20px;
}

.ticket-body {
  white-space: pre-wrap;
  line-height: 1.6;
}

.comment {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.comment:first-child {
  padding-top: 0;
}

.comment:last-child {
  border-bottom: none;
}

.comment-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.comment-body {
  white-space: pre-wrap;
  line-height: 1.5;
}

.comment-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.plain-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.plain-list li:last-child {
  border-bottom: none;
}

/* ---------------------------------------------------------------- responsive */

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

@media (max-width: 760px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .sidebar-brand {
    border-bottom: none;
    border-right: 1px solid var(--border);
  }

  .sidebar-nav {
    display: flex;
    padding: 0;
  }

  .sidebar-nav a {
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
  }

  .sidebar-nav a.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }

  .sidebar-user {
    border-top: none;
    border-left: 1px solid var(--border);
    white-space: nowrap;
  }

  .content {
    padding: 20px;
  }
}

/* -------------------------------------------------------- filter drawer */

.filter-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(31, 43, 40, 0.28);
}

.filter-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 90;
  width: min(360px, 92vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(31, 43, 40, 0.08);
  transform: translateX(100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
  padding: 20px 22px;
  overflow-y: auto;
}

.filter-drawer.is-open {
  transform: translateX(0);
}

.filter-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.filter-drawer-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.filter-drawer-close {
  padding: 6px 12px;
}

.filter-drawer-form .field {
  margin-bottom: 16px;
}

.filter-drawer-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.filter-drawer-form select,
.filter-drawer-form input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
}

.filter-drawer-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

body.filter-drawer-open {
  overflow: hidden;
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
}

.col-check {
  width: 36px;
  text-align: center;
  vertical-align: middle;
}

.col-check input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.audit-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.audit-item {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.audit-item:first-child {
  border-top: none;
  padding-top: 0;
}

.audit-meta {
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.audit-summary {
  font-size: 0.92rem;
}

/* live refresh chip */
.live-chip {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  background: #1b6b4a;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  opacity: 0.92;
}

@media (max-width: 720px) {
  .live-chip {
    right: 10px;
    bottom: 10px;
    font-size: 0.7rem;
    padding: 6px 10px;
  }
}

/* Tetris break */
.tetris-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(280px, 1fr);
  gap: 1.25rem;
  align-items: stretch;
  max-width: 980px;
}
.tetris-play {
  padding: 1.25rem;
}
.tetris-board-side {
  padding: 1.5rem 1.35rem;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: linear-gradient(180deg, #eef8f2 0%, #fff 42%);
  border-color: #c8e6d5;
}
.tetris-champ {
  text-align: center;
  padding: 1.25rem 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.tetris-champ-label {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 700;
  color: #1b6b4a;
}
.tetris-champ-score {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 3.5rem);
  font-weight: 800;
  line-height: 1;
  color: #0b1f17;
}
.tetris-champ-name {
  margin: 0.55rem 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #1b6b4a;
}
.tetris-personal {
  margin: 0 0 1rem;
  font-size: 0.9rem;
}
.tetris-board-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}
.tetris-leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow: auto;
}
.tetris-leaderboard li {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.35rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.tetris-leaderboard li.is-top {
  background: #e5f5ec;
  border-radius: 8px;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  font-weight: 700;
}
.tetris-leaderboard .rank {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tetris-leaderboard .pts {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.tetris-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 0.85rem;
}
.tetris-stat {
  background: #f7faf8;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
}
.tetris-stat strong {
  display: block;
  font-size: 1.1rem;
  margin-top: 0.1rem;
}
.tetris-stat-next canvas {
  display: block;
  margin-top: 0.25rem;
  border-radius: 4px;
  width: 96px;
  height: 96px;
}
#tetris {
  display: block;
  background: #0b1f17;
  border-radius: 8px;
  border: 1px solid var(--border);
  max-width: 100%;
  height: auto;
}
.tetris-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}
@media (max-width: 820px) {
  .tetris-layout {
    grid-template-columns: 1fr;
  }
  .tetris-stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Minesweeper */
.mine-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}
.mine-toolbar label {
  font-size: 0.9rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.mine-toolbar select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.mine-hud {
  display: flex;
  gap: 1rem;
  font-size: 0.95rem;
}
.mine-board {
  --cols: 16;
  display: grid;
  grid-template-columns: repeat(var(--cols), 28px);
  gap: 2px;
  width: max-content;
  max-width: 100%;
  overflow: auto;
  padding: 0.35rem;
  background: #dfe6e9;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.mine-cell {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #b2bec3;
  border-radius: 3px;
  background: linear-gradient(180deg, #ecf0f1, #dfe6e9);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.mine-cell:hover:not(:disabled) {
  background: #fff;
}
.mine-cell.is-open {
  background: #f8f9fa;
  border-color: #dfe6e9;
  cursor: default;
}
.mine-cell.is-flag {
  background: #ffeaa7;
}
.mine-cell.is-mine {
  background: #636e72;
  color: #fff;
}
.mine-cell.is-hit {
  background: #e74c3c;
}
.mine-cell[data-n="1"] { color: #2980b9; }
.mine-cell[data-n="2"] { color: #27ae60; }
.mine-cell[data-n="3"] { color: #c0392b; }
.mine-cell[data-n="4"] { color: #8e44ad; }
.mine-cell[data-n="5"] { color: #d35400; }
.mine-cell[data-n="6"] { color: #16a085; }
.mine-cell[data-n="7"] { color: #2c3e50; }
.mine-cell[data-n="8"] { color: #7f8c8d; }

#flight,
#brickrun {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1f17;
  max-width: none;
  max-height: calc(100vh - 210px);
  object-fit: contain;
}

/* Immersive Flight Sim / Brick Run stage */
body.is-game-page .content {
  max-width: none;
  width: 100%;
  padding: 1.1rem 1.35rem 1.35rem;
}

.game-stage-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.game-stage-header h1 {
  margin: 0;
  font-size: 1.45rem;
}

.game-stage-hint {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.game-stage-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.game-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 1rem;
  align-items: stretch;
  width: 100%;
}

.game-stage-play {
  min-width: 0;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.game-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
}

.game-hud-stat {
  background: #f7faf8;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  min-width: 4.5rem;
}

.game-hud-stat strong {
  display: block;
  font-size: 1.05rem;
  margin-top: 0.05rem;
}

.game-hud-status {
  margin: 0;
  flex: 1 1 160px;
  font-size: 0.9rem;
}

.game-scores {
  padding: 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 130px);
  overflow: auto;
  background: linear-gradient(180deg, #eef8f2 0%, #fff 42%);
  border-color: #c8e6d5;
}

.game-scores .tetris-champ {
  padding: 0.65rem 0.35rem 1rem;
}

.game-scores .tetris-champ-score {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.mine-layout {
  max-width: 1100px;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, 320px);
}

@media (max-width: 980px) {
  .game-stage {
    grid-template-columns: 1fr;
  }
  .game-scores {
    max-height: none;
  }
  #flight,
  #brickrun {
    max-height: min(62vh, 520px);
  }
}

/* Group Uno */
.btn.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.uno-lobby {
  padding: 1.5rem;
  max-width: 900px;
}

.uno-lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.uno-open-rooms {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.uno-open-rooms-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.uno-open-rooms-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.uno-lobby-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.uno-lobby-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7faf8;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.uno-lobby-row:hover {
  background: #e8f5ee;
  border-color: #c8e6d5;
}

.uno-lobby-row strong {
  letter-spacing: 0.12em;
  color: #1b6b4a;
}

.uno-lobby-join {
  font-weight: 700;
  color: #1b6b4a;
  font-size: 0.9rem;
}

.uno-online-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: #e8f5ee;
  color: #1b6b4a;
  font-size: 0.82rem;
  font-weight: 700;
}

.uno-online-pill::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #27ae60;
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.25);
}

.uno-waiting {
  text-align: center;
  padding: 1.5rem 1rem 0.5rem;
}

.uno-waiting-title {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.uno-center-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.uno-pending {
  background: #e74c3c;
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.uno-card.is-dimmed {
  opacity: 0.4;
  filter: grayscale(0.35);
}

.uno-lobby h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.uno-join-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.uno-join-row input {
  width: 7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
  font-size: 1.1rem;
  text-align: center;
}

.uno-error {
  color: #c0392b;
  margin: 1rem 0 0;
}

.uno-table {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: 100%;
}

.uno-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1rem;
}

.uno-code-badge {
  display: inline-block;
  margin: 0 0.5rem 0 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: #e8f5ee;
  color: #1b6b4a;
  letter-spacing: 0.15em;
  font-size: 1.15rem;
}

.uno-message {
  margin: 0;
  flex: 1 1 200px;
  text-align: center;
}

.uno-topbar-actions {
  display: flex;
  gap: 0.5rem;
}

.uno-arena {
  padding: 1rem;
  background: linear-gradient(165deg, #1b6b4a 0%, #0b3d2c 55%, #082820 100%);
  color: #fff;
  border: none;
  min-height: calc(100vh - 210px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.uno-opponents {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}

.uno-seat {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  min-width: 7.5rem;
  text-align: center;
}

.uno-seat.is-active {
  outline: 2px solid #f1c40f;
  background: rgba(241, 196, 15, 0.18);
}

.uno-seat.is-self {
  border-color: rgba(255, 255, 255, 0.45);
}

.uno-seat strong {
  display: block;
  font-size: 0.95rem;
}

.uno-seat-cards {
  font-size: 0.8rem;
  opacity: 0.85;
}

.uno-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex: 1;
  min-height: 160px;
}

.uno-pile {
  border: none;
  background: transparent;
  padding: 0;
}

.uno-draw {
  width: 72px;
  height: 104px;
  border-radius: 10px;
  background: #0b1f17;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  cursor: pointer;
}

.uno-draw:disabled {
  opacity: 0.45;
  cursor: default;
}

.uno-draw strong {
  font-size: 1.2rem;
}

.uno-discard {
  min-width: 72px;
  min-height: 104px;
}

.uno-color-lamp {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.2);
}

.uno-self {
  margin-top: auto;
}

.uno-self-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
}

.uno-turn-flag {
  background: #f1c40f;
  color: #0b1f17;
  font-weight: 800;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.uno-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  align-items: flex-end;
}

.uno-card {
  width: 70px;
  height: 100px;
  border-radius: 10px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  position: relative;
}

.uno-card.is-playable:hover {
  transform: translateY(-10px) scale(1.04);
  z-index: 2;
}

.uno-card.is-disabled {
  cursor: default;
  opacity: 0.92;
}

.uno-card.r { background: linear-gradient(160deg, #e74c3c, #c0392b); }
.uno-card.y { background: linear-gradient(160deg, #f1c40f, #d4ac0d); color: #1a1a1a; }
.uno-card.g { background: linear-gradient(160deg, #27ae60, #1e8449); }
.uno-card.b { background: linear-gradient(160deg, #3498db, #2471a3); }
.uno-card.wild {
  background: conic-gradient(#e74c3c, #f1c40f, #27ae60, #3498db, #e74c3c);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.uno-card-rank {
  font-size: 1.15rem;
  background: rgba(0, 0, 0, 0.22);
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
}

.uno-card.y .uno-card-rank {
  background: rgba(0, 0, 0, 0.12);
}

.uno-color-picker {
  position: fixed;
  inset: 0;
  background: rgba(11, 31, 23, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 40;
  color: #fff;
}

.uno-color-choices {
  display: flex;
  gap: 0.75rem;
}

.uno-swatch {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid #fff;
  cursor: pointer;
}

.uno-swatch.r { background: #e74c3c; }
.uno-swatch.y { background: #f1c40f; }
.uno-swatch.g { background: #27ae60; }
.uno-swatch.b { background: #3498db; }

@media (max-width: 760px) {
  .uno-lobby-grid {
    grid-template-columns: 1fr;
  }
  .uno-card {
    width: 58px;
    height: 84px;
  }
}


