:root {
  --event-primary: #2563eb;
  --team-color: #2563eb;
  --bg: #f5f7fb;
  --text: #111827;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.12);
  --glass: rgba(255, 255, 255, 0.86);
  --shadow: 0 24px 70px rgba(15, 23, 42, 0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
#map { position: fixed; inset: 0; z-index: 1; filter: saturate(.82) contrast(.96) brightness(1.03); }

.entry-page { min-height: 100%; overflow: auto; background: linear-gradient(135deg, rgba(37,99,235,.12), transparent 38%), radial-gradient(circle at 82% 16%, rgba(20,184,166,.18), transparent 30%), var(--bg); }
.entry-shell { width: min(1060px, calc(100% - 32px)); min-height: 100vh; margin: 0 auto; display: grid; align-content: center; gap: 24px; padding: 34px 0; }
.entry-hero { max-width: 760px; }
.entry-hero h1 { margin: 0; font-size: clamp(3rem, 10vw, 7rem); line-height: .9; letter-spacing: -.07em; }
.entry-logo { display: block; width: min(560px, 100%); height: auto; margin: 0 0 10px; }
.entry-hero p:not(.eyebrow) { max-width: 620px; color: var(--muted); font-size: clamp(1rem, 2vw, 1.18rem); line-height: 1.6; }
.entry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.entry-card { min-height: 230px; display: grid; align-content: end; gap: 10px; padding: clamp(22px, 4vw, 34px); border: 1px solid rgba(255,255,255,.82); border-radius: 28px; background: rgba(255,255,255,.72); color: var(--text); text-decoration: none; box-shadow: var(--shadow); backdrop-filter: blur(24px) saturate(1.18); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.entry-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--team-color) 36%, rgba(255,255,255,.82)); box-shadow: 0 28px 80px rgba(15,23,42,.2); }
.entry-card strong { font-size: clamp(1.55rem, 3vw, 2.4rem); letter-spacing: -.05em; }
.entry-card small { max-width: 390px; color: var(--muted); font-size: .98rem; line-height: 1.5; }
.entry-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; background: var(--team-color); color: #fff; font-weight: 900; box-shadow: 0 16px 42px color-mix(in srgb, var(--team-color) 26%, transparent); }
.gm-entry { --team-color: #111827; }
.entry-footer { display: flex; justify-content: center; padding-top: 4px; }

.setup { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, rgba(37,99,235,.12), transparent 38%), radial-gradient(circle at 85% 18%, rgba(20,184,166,.15), transparent 30%), var(--bg); }
.setup.hidden { display: none; }
.setup-card { width: min(680px, 100%); max-height: 92vh; overflow: auto; padding: clamp(24px, 5vw, 42px); border: 1px solid rgba(255,255,255,.78); border-radius: 30px; background: var(--glass); box-shadow: var(--shadow); backdrop-filter: blur(26px) saturate(1.2); }
.eyebrow { margin: 0 0 8px; color: var(--team-color); font-size: .75rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.setup h1 { margin: 0; font-size: clamp(2.3rem, 7vw, 4.6rem); line-height: .96; letter-spacing: -.04em; }
.setup p { color: var(--muted); line-height: 1.55; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 7px; margin: 14px 0; color: #334155; font-weight: 800; }
.field input, .field select, .modal-input { width: 100%; min-height: 46px; border: 1px solid var(--border); border-radius: 14px; background: rgba(248,250,252,.94); color: var(--text); padding: 11px 12px; outline: none; }
.checkin-field { display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: 8px; }
.checkin-field button { display: grid; place-items: center; min-height: 46px; border: 1px solid var(--border); border-radius: 14px; background: #111827; color: #fff; font-size: 1.1rem; box-shadow: 0 10px 24px rgba(15,23,42,.14); }
.team-picker { display: grid; gap: 10px; margin: 16px 0; }
.team-choice { display: flex; align-items: center; gap: 12px; min-height: 56px; border: 1px solid var(--border); border-radius: 16px; background: rgba(255,255,255,.7); color: var(--text); padding: 12px 14px; text-align: left; font-weight: 900; }
.team-choice span { width: 20px; height: 20px; border-radius: 50%; background: var(--team-color); box-shadow: 0 0 0 5px color-mix(in srgb, var(--team-color) 16%, transparent); }
.team-choice.active { border-color: var(--team-color); box-shadow: 0 12px 28px color-mix(in srgb, var(--team-color) 18%, transparent); }

.hud { position: fixed; top: max(14px, env(safe-area-inset-top)); left: 14px; right: 14px; z-index: 500; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; pointer-events: none; }
.event-card, .hud-stats, .icon-btn { pointer-events: auto; border: 1px solid rgba(255,255,255,.76); background: var(--glass); box-shadow: 0 10px 34px rgba(15,23,42,.14); backdrop-filter: blur(22px) saturate(1.2); }
.event-card { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px 12px; border-radius: 22px; }
.logo-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 16px; background: var(--team-color); color: #fff; font-weight: 900; }
.event-card h1 { margin: 0; font-size: clamp(1rem, 3vw, 1.35rem); letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-card p { margin: 3px 0 0; color: var(--team-color); font-size: .84rem; font-weight: 800; }
.hud-stats { display: flex; gap: 8px; padding: 8px; border-radius: 20px; }
.hud-stats span { min-width: 72px; padding: 8px 10px; border-radius: 14px; background: rgba(15,23,42,.06); text-align: center; font-size: .9rem; font-weight: 900; }
.icon-btn { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; border: 0; color: var(--text); font-size: 1.35rem; }

.panel-overlay { position: fixed; inset: 0; z-index: 800; display: none; background: rgba(15,23,42,.24); backdrop-filter: blur(2px); }
.panel-overlay.show { display: block; }
.panel { position: fixed; top: 10px; right: 10px; bottom: 10px; z-index: 900; width: min(460px, calc(100vw - 20px)); transform: translateX(calc(100% + 18px)); transition: transform .25s cubic-bezier(.2,.8,.2,1); overflow: auto; padding: max(18px, env(safe-area-inset-top)) 16px 18px; border: 1px solid rgba(255,255,255,.76); border-radius: 30px; background: var(--glass); box-shadow: var(--shadow); backdrop-filter: blur(28px) saturate(1.2); }
.panel.open { transform: translateX(0); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 1.55rem; letter-spacing: -.03em; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1; min-height: 40px; padding: 0 8px; border: 1px solid transparent; border-radius: 20px; background: rgba(15,23,42,.04); color: var(--muted); font-weight: 800; font-size: 0.82rem; white-space: nowrap; text-align: center; transition: all .2s; }
.tab.active { background: var(--team-color); color: #fff; box-shadow: 0 8px 24px color-mix(in srgb, var(--team-color) 26%, transparent); }

.secondary-action { min-height: 44px; border: 1px solid var(--border); border-radius: 14px; background: rgba(255,255,255,.66); color: #334155; font-weight: 900; }
.primary-action { min-height: 44px; border: 0; border-radius: 14px; background: var(--team-color); color: #fff; font-weight: 900; box-shadow: 0 12px 30px color-mix(in srgb, var(--team-color) 24%, transparent); }

.final-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.final-grid div { padding: 12px 8px; border: 1px solid rgba(15,23,42,.08); border-radius: 16px; background: rgba(248,250,252,.9); text-align: center; }
.final-grid strong { display: block; }
.final-grid span { color: var(--muted); font-size: .72rem; font-weight: 700; }
.finish-game-wrapper { margin-top: 16px; padding-top: 16px; border-top: 1px dashed rgba(15,23,42,.1); }

.panel-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(15,23,42,.08); }
.ghost-action { background: transparent; border: 0; color: var(--muted); font-size: 0.8rem; font-weight: 700; text-decoration: underline; text-underline-offset: 4px; padding: 4px; min-height: auto; }
.ghost-action:hover { color: var(--text); }
.smart-commerce-logo { width: 100%; text-align: center; margin-top: 4px; color: #26313f; font-size: .94rem; font-weight: 900; text-decoration: none; letter-spacing: -0.03em; }
.smart-commerce-logo span { color: #facc15; }

.task-card, .agenda-item, .ranking-row, .info-block { border: 1px solid rgba(15,23,42,.08); border-radius: 18px; background: rgba(255,255,255,.76); overflow: hidden; margin-bottom: 10px; }
.task-card.done { border-color: rgba(34,197,94,.45); background: rgba(240,253,244,.9); }
.task-card > button { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 10px; align-items: center; width: 100%; border: 0; background: transparent; padding: 13px; text-align: left; }
.task-card strong, .task-card small { display: block; }
.task-card small { color: var(--muted); }
.task-card p { margin: 0; padding: 0 13px 13px; color: #475569; line-height: 1.45; }
.task-index { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 11px; background: var(--task-color, var(--team-color)); color: #fff; font-weight: 900; }
.task-card { border-left: 5px solid var(--task-color, var(--team-color)); }
.task-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 13px 13px; }
.task-actions button { min-height: 38px; border: 1px solid var(--border); border-radius: 12px; background: rgba(15,23,42,.05); font-weight: 900; }
.agenda-item { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 13px; }
.agenda-item time { color: var(--team-color); font-weight: 900; }
.agenda-item span, .ranking-row em { display: block; color: var(--muted); font-style: normal; }
.ranking-row { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: center; padding: 12px; border-left: 5px solid var(--team-color); }
.info-block { display: grid; gap: 5px; padding: 13px; }
.info-block span { color: var(--muted); line-height: 1.45; }

.event-marker { width: 30px; height: 30px; background: transparent; }
.event-marker::before { content: ""; position: absolute; inset: 0; transform: rotate(-45deg); border-radius: 50% 50% 50% 0; background: var(--marker-color, #000); border: 3px solid #fff; box-shadow: 0 8px 24px rgba(15,23,42,.32); }
.event-marker.done::before { background: #22c55e; }
.event-marker::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: rgba(255,255,255,.88); }

.user-dot { width: 18px; height: 18px; border-radius: 50%; background: #0ea5e9; border: 3px solid #fff; box-shadow: 0 0 0 8px rgba(14,165,233,.18); }
.event-popup .leaflet-popup-content-wrapper { border-radius: 20px; background: rgba(255,255,255,.96); color: var(--text); box-shadow: var(--shadow); }
.event-popup .leaflet-popup-tip { background: rgba(255,255,255,.96); }
.popup h3 { margin: 4px 0; }
.popup p { margin: 0; color: var(--team-color); font-size: .75rem; font-weight: 900; text-transform: uppercase; }
.popup span { color: var(--muted); }
.popup button { width: 100%; min-height: 38px; margin-top: 8px; border: 0; border-radius: 12px; background: var(--team-color); color: #fff; font-weight: 900; }
.popup button.soft { background: rgba(15,23,42,.06); color: #0f172a; }
.leaflet-control-zoom { border: 0 !important; box-shadow: 0 10px 34px rgba(15,23,42,.14) !important; }
.leaflet-control-zoom a { width: 42px !important; height: 42px !important; line-height: 42px !important; border: 1px solid rgba(255,255,255,.76) !important; background: rgba(255,255,255,.92) !important; color: #0f172a !important; font-weight: 900 !important; }
.leaflet-control-zoom-in { border-radius: 14px 14px 0 0 !important; }
.leaflet-control-zoom-out { border-radius: 0 0 14px 14px !important; }
.leaflet-control-attribution { border-radius: 10px 0 0 0; background: rgba(255,255,255,.72) !important; color: #475569 !important; }

.fab-gps { position: fixed; right: 16px; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 400; width: 56px; height: 56px; border-radius: 28px; border: 0; background: #fff; color: var(--text); font-size: 1.5rem; box-shadow: 0 12px 36px rgba(15,23,42,.18); display: grid; place-items: center; transition: transform .2s; }
.fab-gps:active { transform: scale(0.92); }

.game-start-overlay { position: fixed; inset: 0; z-index: 600; background: rgba(255,255,255,0.4); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 20px; }
.game-start-overlay[hidden] { display: none; }
.start-card { width: min(400px, 100%); padding: 32px; border-radius: 32px; background: rgba(255,255,255,0.95); box-shadow: var(--shadow); text-align: center; border: 1px solid rgba(255,255,255,.8); }
.start-card h2 { margin: 0 0 12px; font-size: 2rem; letter-spacing: -.03em; color: var(--team-color); }
.start-card p { margin: 0 0 24px; color: var(--muted); line-height: 1.5; font-size: 1.05rem; }

.route-cancel { position: fixed; left: 16px; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 700; min-height: 44px; padding: 10px 14px; border: 1px solid rgba(255,255,255,.76); border-radius: 14px; background: rgba(255,255,255,.92); color: #dc2626; box-shadow: 0 10px 34px rgba(15,23,42,.16); font-weight: 900; backdrop-filter: blur(18px); }
.route-cancel[hidden] { display: none; }

.modal { position: fixed; inset: 0; z-index: 12000; display: grid; place-items: center; padding: 18px; background: rgba(15,23,42,.32); backdrop-filter: blur(6px); }
.modal[hidden] { display: none; }
.modal-card { position: relative; width: min(620px, 100%); max-height: 90vh; overflow: auto; padding: 26px; border: 1px solid rgba(255,255,255,.76); border-radius: 28px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 0 12px; letter-spacing: -.03em; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.wide { width: 100%; margin-top: 10px; }
.answer-list { display: grid; gap: 8px; }
.answer-list button { min-height: 42px; border: 1px solid var(--border); border-radius: 14px; background: rgba(248,250,252,.94); font-weight: 900; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 14px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; }
.intro-steps { display: grid; gap: 10px; margin: 16px 0; padding-left: 22px; color: #334155; line-height: 1.45; }
.intro-steps li::marker { color: var(--team-color); font-weight: 900; }
.survey-box { display: grid; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.survey-box h3 { margin: 0; }
.survey-box label { display: grid; gap: 7px; color: #334155; font-weight: 800; }
.survey-box select { min-height: 42px; border: 1px solid var(--border); border-radius: 12px; background: rgba(248,250,252,.94); padding: 8px 10px; }
.qr-card video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 18px; background: #0f172a; }
.qr-card p:last-child { margin-bottom: 0; color: var(--muted); line-height: 1.45; }
.toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 13000; width: min(380px, calc(100vw - 32px)); transform: translateX(-50%); padding: 13px 16px; border-radius: 16px; background: rgba(17,24,39,.92); color: #fff; text-align: center; font-weight: 900; box-shadow: 0 10px 34px rgba(15,23,42,.22); }

@media (max-width: 760px) {
  .entry-grid { grid-template-columns: 1fr; }
  .entry-card { min-height: 190px; }
  .hud { grid-template-columns: minmax(0,1fr) auto; }
  .hud-stats { grid-column: 1 / -1; justify-content: stretch; }
  .hud-stats span { flex: 1; min-width: 0; }
  .setup-grid { grid-template-columns: 1fr; }
  .final-grid { grid-template-columns: repeat(2, 1fr); }
}

.math-expr { font-size: 1.8rem; font-weight: 900; color: var(--primary); text-align: center; margin: 15px 0; background: #f8fafc; padding: 20px; border-radius: 16px; border: 2px dashed var(--border); }
.sensor-ui { text-align: center; padding: 30px 20px; }
.sensor-indicator { width: 80px; height: 80px; background: var(--primary); border-radius: 50%; margin: 0 auto 20px; transition: transform 0.1s ease; box-shadow: 0 0 20px color-mix(in srgb, var(--primary) 40%, transparent); }
.compass-ui { text-align: center; padding: 30px 20px; }
.compass-arrow { font-size: 5rem; margin-bottom: 15px; display: inline-block; transition: transform 0.1s ease; color: var(--primary); }

/* --- CHAT STYLES --- */
.chat-view {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 250px);
}
.chat-view[hidden] {
  display: none !important;
}
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 40px;
  padding: 0 20px;
  line-height: 1.5;
}
.chat-msg {
  max-width: 85%;
  display: flex;
  flex-direction: column;
}
.msg-me {
  align-self: flex-end;
  align-items: flex-end;
}
.msg-gm {
  align-self: flex-start;
  align-items: flex-start;
}
.msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.94rem;
  line-height: 1.4;
  word-wrap: break-word;
}
.msg-me .msg-bubble {
  background: var(--team-color);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--team-color) 20%, transparent);
}
.msg-gm .msg-bubble {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 600;
}
.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  background: var(--glass);
}
.chat-input-area input {
  flex: 1;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 14px;
  outline: none;
  background: rgba(248, 250, 252, 0.8);
}
.chat-input-area button {
  padding: 0 16px;
}

