:root {
  --bg: #0f1420;
  --panel: #1a2233;
  --panel-2: #232d42;
  --text: #f0f3fa;
  --muted: #8b96ac;
  --accent: #4f8cff;
  --good: #2ecc71;
  --bad: #ff5555;
  --p: #f5a623;
  --d: #2ecc71;
  --c: #29b6f6;
  --a: #ff5252;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

h1, h2, h3 { margin: 0 0 12px; }

.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

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

.role-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
  color: #10131c;
}
.role-P { background: var(--p); }
.role-D { background: var(--d); }
.role-C { background: var(--c); }
.role-A { background: var(--a); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: white;
  width: 100%;
  transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-secondary { background: var(--panel-2); color: var(--text); }
.btn-good { background: var(--good); color: #0a1f12; }
.btn-bad { background: var(--bad); }

.bid-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.bid-grid .btn { padding: 18px 6px; font-size: 18px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row + .row { margin-top: 8px; }

.stat {
  text-align: center;
  padding: 10px;
}
.stat .value { font-size: 28px; font-weight: 800; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.timer-bar-outer {
  width: 100%;
  height: 14px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}
.timer-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--good), var(--p) 60%, var(--bad));
  transition: width .08s linear;
}

.player-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border: 2px solid transparent;
}
.player-item:active { border-color: var(--accent); }
.player-item .name { font-weight: 700; flex: 1; }
.player-item .team { color: var(--muted); font-size: 13px; }
.player-item .quotation {
  color: var(--p);
  font-weight: 800;
  font-size: 13px;
  min-width: 26px;
  text-align: right;
}

input[type=text], input[type=password], input[type=number], select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #2c3750;
  background: var(--panel-2);
  color: var(--text);
  font-size: 16px;
}

.search-box { position: sticky; top: 0; background: var(--panel); padding-bottom: 8px; }

.sort-row { display: flex; gap: 6px; margin-top: 8px; }
.sort-btn {
  flex: 1;
  background: var(--panel-2);
  color: var(--muted);
  border: none;
  border-radius: 8px;
  padding: 7px 4px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.sort-btn.active { background: var(--accent); color: #fff; }

.header-compact { padding: 10px 16px; margin-bottom: 10px; }
.header-compact .row { font-size: 14px; }
.header-compact .hc-credits { font-size: 15px; }
.header-compact .hc-roster {
  display: flex;
  gap: 14px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  padding: 12px 18px;
  border-radius: 10px;
  z-index: 50;
  max-width: 90%;
  text-align: center;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--panel-2); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }

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

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--panel-2);
}
.badge-turn { background: var(--accent); }

.center { text-align: center; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 18px;
}
.topbar .title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .02em;
}
.topbar .title .ball {
  display: inline-block;
  margin-right: 2px;
}
.topbar .subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

@keyframes ball-bounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(180deg); }
}
.ball-bounce { display: inline-block; animation: ball-bounce 1.6s ease-in-out infinite; }

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.icon-tile {
  position: relative;
  background: var(--panel);
  border: none;
  border-radius: var(--radius);
  padding: 18px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: transform .05s ease, background .15s ease;
}
.icon-tile:active { transform: scale(0.96); }
.icon-tile:hover { background: var(--panel-2); }
.icon-tile-emoji { font-size: 30px; line-height: 1; }
.icon-tile-label { font-size: 13px; font-weight: 700; text-align: center; }
.icon-tile-badge { position: absolute; top: 8px; right: 10px; font-size: 13px; }
.icon-tile.danger { border: 1px solid var(--bad); }
.icon-tile.danger .icon-tile-label { color: var(--bad); }

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  z-index: 60;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px;
  width: 100%;
  max-width: 560px;
  margin: 24px 0;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.modal-header h3 { margin: 0; }
.modal-close {
  background: var(--panel-2);
  border: none;
  color: var(--text);
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
