/* Egységes megjelenés a menükhöz és a kijelzőkhöz. A style.css elrendezéseire épül. */
:root {
  --panel: rgba(11, 15, 24, 0.8);
  --card: rgba(14, 19, 30, 0.94);
  --surface: rgba(255, 255, 255, 0.045);
  --line: rgba(148, 170, 210, 0.16);
  --line-strong: rgba(148, 170, 210, 0.32);
  --muted: #9aa8bf;
  --red-dark: #a70713;
  --radius: 14px;
  --glow: 0 0 0 3px rgba(255, 209, 102, 0.28);
}

/* ---------- Vezérlők ---------- */
button {
  border-color: var(--line); background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  border-radius: 10px; transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); border-color: var(--line-strong); }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary { background: linear-gradient(135deg, #ff2b1f, var(--red-dark)); border-color: transparent; box-shadow: 0 6px 18px rgba(225, 6, 0, 0.28); }
button.primary:hover:not(:disabled) { background: linear-gradient(135deg, #ff4a3d, #c40a17); }
button.primary:disabled { box-shadow: none; filter: grayscale(0.7); }
button.ghost { background: transparent; }
button.big { border-radius: 12px; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: none; box-shadow: var(--glow); border-color: var(--accent); }
input, select {
  background: rgba(7, 11, 20, 0.75); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; transition: border-color 0.15s, box-shadow 0.15s;
}
input:hover:not(:disabled), select:hover:not(:disabled) { border-color: var(--line-strong); }
select:disabled, input:disabled { opacity: 0.55; }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 6px; padding: 0; border: 0; border-radius: 3px; background: rgba(255, 255, 255, 0.14); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid var(--red); cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 4px solid var(--red); cursor: pointer; }
input[type="checkbox"] { accent-color: var(--red); width: 17px; height: 17px; }
input.switch {
  -webkit-appearance: none; appearance: none; position: relative; flex: none; width: 44px; height: 24px; margin: 0; padding: 0;
  border-radius: 12px; background: rgba(255, 255, 255, 0.16); cursor: pointer; transition: background 0.2s;
}
input.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
input.switch:checked { background: var(--red); }
input.switch:checked::after { transform: translateX(20px); }

/* ---------- Kártyák, fejlécek ---------- */
body.in-menu #menu .screen:not([data-screen="main"]) { background: radial-gradient(circle at 20% 0%, rgba(225, 6, 0, 0.14), transparent 55%); }
.card {
  position: relative; border-radius: 20px; padding: 22px 26px; border-color: var(--line);
  background: linear-gradient(165deg, rgba(23, 30, 46, 0.96), rgba(11, 15, 25, 0.96));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.card::before { content: ""; position: absolute; left: 26px; right: 26px; top: 0; height: 3px; border-radius: 0 0 3px 3px; background: linear-gradient(90deg, var(--red), var(--accent), transparent); }
.screen.active .card, .modal.show .card { animation: rise 0.22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .screen.active .card, .modal.show .card { animation: none; } }
.card header { gap: 16px; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.card header h2 { font-size: 24px; font-style: italic; font-weight: 800; letter-spacing: -0.01em; }
.card footer { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); align-items: center; }
h3 { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 18px 0 10px; }
h3::before { content: ""; width: 14px; height: 3px; border-radius: 2px; background: var(--red); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; padding: 4px; border-radius: 12px; background: rgba(0, 0, 0, 0.3); }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); }
.tabs button.on, .tabs button.on:hover { background: var(--red); color: #fff; }

/* ---------- Listák, táblák, csapatok ---------- */
.track-card canvas { background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02)); border: 1px solid var(--line); border-radius: var(--radius); }
.team { position: relative; border-radius: var(--radius); background: var(--surface); transition: transform 0.15s, border-color 0.15s; }
.team:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.team.chosen { border-color: var(--accent); border-top-color: var(--team); background: rgba(255, 209, 102, 0.08); }
.edit-team { width: 100%; margin-top: 7px; padding: 6px; font-size: 12px; border-color: var(--accent); color: var(--accent); }
.meter i { background: linear-gradient(90deg, var(--red), var(--accent)); }
#rooms li, #members li { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.chatlog { border: 1px solid var(--line); border-radius: 11px; }
th { text-transform: uppercase; font-size: 11px; letter-spacing: 0.07em; }
tr:hover td { background: rgba(255, 255, 255, 0.03); }
.tile, .offer, .upgrade, .trophy-card { border-radius: var(--radius); }
.shop { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); }
#livery-preview, #editor-preview { border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- Beállítások ---------- */
.groups { display: grid; grid-template-columns: 1fr; gap: 12px; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px 6px; }
.group h3 { margin: 12px 0 4px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.group h3 + .row { border-top: 0; }
.row > span { display: flex; flex-direction: column; gap: 2px; }
.row b { font-size: 14px; }
.row small { color: var(--muted); font-size: 12px; }
.row select, .row input:not(.switch), .row button { width: 200px; flex: none; }

/* ---------- Segítség ---------- */
.keygrid, .infogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.keycard, .info { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.keycard { display: flex; flex-direction: column; gap: 3px; }
.keycard small { color: var(--muted); font-size: 12px; }
.keys { display: flex; gap: 6px; margin-bottom: 8px; }
kbd {
  min-width: 38px; padding: 8px 10px; text-align: center; font: 800 14px/1 "Segoe UI", system-ui, sans-serif;
  border: 1px solid var(--line-strong); border-bottom-width: 4px; border-radius: 8px; background: linear-gradient(180deg, #2b364f, #1a2235);
}
.info .icon { font-size: 26px; }
.info h4 { margin: 8px 0 4px; font-size: 15px; }
.info p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ---------- Versenyhétvége ---------- */
.calendar { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.calendar li { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.calendar small { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.calendar span { font-size: 12px; font-weight: 700; color: var(--accent); min-height: 17px; }
.calendar li.now { border-color: var(--red); background: rgba(225, 6, 0, 0.16); }
.calendar li.past { opacity: 0.75; }
.calendar .met { color: #06d6a0; }
.calendar .missed { color: #ff6b81; }
.objective {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; margin-top: 16px; padding: 16px;
  border: 1px solid var(--accent); border-radius: var(--radius); background: linear-gradient(110deg, rgba(255, 209, 102, 0.14), rgba(225, 6, 0, 0.08));
}
.objective > div:first-child { display: flex; flex-direction: column; gap: 9px; }
.objective > div:first-child b { font-size: 19px; }
.heat { display: flex; gap: 3px; }
.heat i { width: 20px; height: 7px; border-radius: 3px; background: rgba(255, 255, 255, 0.14); }
.heat i.on { background: linear-gradient(90deg, var(--accent), var(--red)); }
.stakes { display: flex; gap: 8px; flex-wrap: wrap; }
.stakes .tile b { font-size: 18px; white-space: nowrap; }
.stakes .plus b { color: #7ee8a7; }
.stakes .minus b { color: #ff6b81; }
.stakes .budget b { color: var(--accent); }
#hub-wait { margin: 0 auto 0 0; }
body.hub-open #results, body.hub-open #hud, body.hub-open #ceremony, body.hub-open #announcer { display: none; }

/* ---------- Ablakok, belépés, szerkesztő ---------- */
.modal { position: fixed; inset: 0; display: none; overflow: auto; padding: 18px; z-index: 15; background: rgba(4, 7, 12, 0.78); }
.modal.show { display: flex; }
#editor-saved li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 5px; border: 1px solid var(--line); border-radius: 10px; }
#editor-saved li.note { border: 0; padding: 0; }
#editor-saved .name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
#editor-saved button { padding: 4px 10px; font-size: 12px; }
#editor-preview { width: 100%; height: auto; display: block; background: #2a303b; }
#editor .columns.three { grid-template-columns: minmax(260px, 1.2fr) 1fr 1fr; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#gate { z-index: 30; background: linear-gradient(120deg, rgba(5, 8, 14, 0.95), rgba(40, 6, 12, 0.88)); }
.gate-box { margin: auto; width: min(420px, 100%); }
.gate-box .logo { margin-bottom: 16px; }
#gate-form { display: flex; flex-direction: column; gap: 6px; }
#gate-form .field { font-size: 13px; }
#gate-error { margin: 2px 0; min-height: 18px; color: #ff8a98; font-size: 13px; font-weight: 700; }
#gate-local { width: 100%; }
.divider { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Főmenü és profil ---------- */
.account-line { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--muted); }
.account-line button { padding: 4px 10px; font-size: 12px; }
.db-history { margin-top: 6px; }

/* ---------- Story mód ---------- */
.tile-btn.hero { grid-column: span 2; }
.tile-btn.hero.story { background: linear-gradient(115deg, #b8860b 0%, #6d4c05 60%, #2c1d02 100%); }
.tile-btn.hero.story:hover:not(:disabled), .tile-btn.hero.story:focus-visible { background: linear-gradient(115deg, #d9a216 0%, #87600a 60%, #3d2a05 100%); }
.story-start p { color: var(--muted); line-height: 1.55; max-width: 70ch; }
.story-layout { display: grid; grid-template-columns: 250px 1fr; gap: 20px; }
.story-side { display: flex; flex-direction: column; gap: 10px; }
.story-team { display: flex; flex-direction: column; padding: 10px 14px; border-left: 5px solid; border-radius: 10px; background: var(--surface); }
.story-team small, .kicker { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.story-stat { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; font-size: 12px; color: var(--muted); }
.story-stat b { color: var(--text); }
.story-stat .meter { grid-column: 1 / -1; display: block; height: 5px; }
.story-stat .meter i { transition: width 0.4s; }
.story-road li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 8px; border-left: 2px solid var(--line); font-size: 12px; color: var(--muted); }
.story-road li.now { border-color: var(--red); color: var(--text); font-weight: 700; }
.story-road li.past { border-color: var(--accent); }
.story-road .met { color: #06d6a0; }
.story-road .missed { color: #ff6b81; }
.story-stage { display: flex; flex-direction: column; min-width: 0; }
.story-stage h4 { margin: 2px 0 12px; font-size: 22px; font-style: italic; }
.dialog { display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow: auto; padding-right: 6px; scroll-behavior: smooth; }
.bubble { display: flex; gap: 10px; align-items: flex-start; max-width: 88%; animation: rise 0.25s ease-out; }
.bubble .avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 900; border: 2px solid rgba(255, 255, 255, 0.35); }
.bubble > div { padding: 9px 13px; border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; background: var(--surface); }
.bubble small { color: var(--accent); font-size: 11px; font-weight: 700; }
.bubble p { margin: 3px 0 0; font-size: 14px; line-height: 1.5; }
.bubble.me { flex-direction: row-reverse; align-self: flex-end; }
.bubble.me > div { border-radius: 14px 4px 14px 14px; background: rgba(225, 6, 0, 0.16); }
.story-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.story-controls .choice { flex: 1 1 200px; text-align: left; padding: 12px 14px; border-color: var(--accent); }
.briefing { padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.briefing.success { border-color: #06d6a0; background: rgba(6, 214, 160, 0.09); }
.briefing.failure { border-color: #ff6b81; background: rgba(255, 107, 129, 0.08); }
.briefing p { margin: 6px 0; }
.briefing .goal { font-size: 17px; font-weight: 800; }
.briefing .bonus { color: var(--accent); }
.briefing .place { font-size: 40px; font-weight: 900; font-style: italic; }
@media (max-width: 760px) {
  .story-layout { grid-template-columns: 1fr; }
  .story-side { order: 2; }
  .tile-btn.hero { grid-column: 1 / -1; }
}

/* ---------- Futam közbeni panelek és eredmények ---------- */
.panel { border: 1px solid var(--line); border-radius: var(--radius); }
#tower, #topright { border-top: 3px solid var(--red); }
#results { border-radius: 20px; border-top: 3px solid var(--red); background: linear-gradient(165deg, rgba(23, 30, 46, 0.96), rgba(11, 15, 25, 0.96)); }
#results h2 { font-style: italic; }

@media (max-width: 900px) {
  #editor .columns.three { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .card { padding: 18px 16px; }
  .row { flex-wrap: wrap; }
  .row select, .row input:not(.switch), .row button { width: 100%; }
}
@media (max-height: 700px) {
  .account-line { margin-top: 0; }
  .home .lead { display: none; }
}

/* ---------- Keskeny képernyő: semmi ne lógjon ki ---------- */
.settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field select, .field input { width: 100%; max-width: 100%; }
.sector-table th { white-space: normal; width: auto; letter-spacing: 0; }
@media (max-width: 560px) {
  .sector-table th, .sector-table td { padding: 3px; font-size: 11px; }
  .columns.two > div { overflow-x: auto; }
}

/* ---------- Érintős irányítás ---------- */
#touch { display: none; }
body.touch #touch { display: block; }
body.spectating #touch .left, body.spectating #touch .right, body.ceremony #touch { display: none; }
#touch .pad { position: fixed; display: flex; gap: 10px; align-items: flex-end; z-index: 3; }
#touch .left { left: 12px; bottom: 14px; }
#touch .right { right: 12px; bottom: 14px; }
#touch .tools { left: 50%; bottom: 14px; transform: translateX(-50%); gap: 6px; }
#touch button { width: 70px; height: 70px; padding: 0; border-radius: 50%; font-size: 26px; background: var(--panel); touch-action: none; -webkit-touch-callout: none; }
#touch button.gas { height: 96px; border-radius: 36px; border-color: #06d6a0; }
#touch button.small { width: 56px; height: 56px; font-size: 20px; }
#touch .tools button { width: 40px; height: 40px; font-size: 16px; }
#touch button.down { background: var(--red); }
body.touch #bottomright { bottom: auto; top: 46%; }

/* ---------- Keskeny kijelző futam közben ---------- */
@media (max-width: 720px) {
  #tower, #topright, #bottomright { zoom: calc(var(--hud-scale, 1) * 0.62); }
  #gaps, #carstatus .damage, #ping, #setup-info { display: none; }
  #bottomright { flex-direction: column; align-items: flex-end; }
  #announcer { top: auto; bottom: 34%; font-size: 12px; }
  #radio { bottom: 27%; font-size: 12px; }
  #flag { top: auto; bottom: 41%; font-size: 12px; white-space: normal; width: max-content; max-width: 90vw; }
  #overtake { top: 38%; }
  #center { font-size: 40px; white-space: normal; width: 90vw; }
  body:not(.touch) #bottomright { bottom: 8px; right: 8px; }
  body.touch #bottomright { top: 362px; right: 8px; }
  body.touch #touch .tools { bottom: 128px; }
  #touch button { width: 62px; height: 62px; }
  #touch .pad { gap: 6px; }
  #touch button.gas { height: 86px; }
}
