/* ============================================
   ŠKODA 5S minihra – styly
   ============================================ */

:root {
  --skoda-green-dark: #0E3D2E;
  --skoda-green-mid: #14543F;
  --skoda-green-light: #9FE5B0;
  --skoda-green-line: #1F6A4F;
  --skoda-orange: #F7A92A;
  --skoda-orange-soft: #FFCB6B;
  --skoda-red: #E63946;
  --skoda-red-dark: #B22B36;
  --skoda-white: #FFFFFF;
  --skoda-cream: #F5F1E6;
  --ink: #0B2A20;
  --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.18);
  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-phone: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius-card: 14px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: var(--skoda-green-dark);
  color: var(--skoda-white);
  min-height: 100vh;
  min-height: 100dvh;
}

button { font-family: inherit; }

/* ===== Page wrapper (desktop background canvas) ===== */
.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background:
    radial-gradient(ellipse at top left, rgba(159, 229, 176, 0.05) 0, transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(247, 169, 42, 0.05) 0, transparent 60%),
    var(--skoda-green-dark);
}

/* ===== Container ===== */
.phone {
  width: 100%;
  max-width: 420px;
  height: 100vh;
  height: 100dvh;
  max-height: 920px;
  position: relative;
}

.phone-inner {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--skoda-green-dark);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* On larger viewports we go wider but always keep full viewport height */
@media (min-width: 640px) {
  .page { padding: 0; }
  .phone {
    max-width: 600px;
    height: 100vh;
    height: 100dvh;
    max-height: none;
  }
  .phone-inner {
    border-left: 1px solid rgba(159, 229, 176, 0.12);
    border-right: 1px solid rgba(159, 229, 176, 0.12);
    box-shadow: var(--shadow-phone);
  }
}

@media (min-width: 900px) {
  .phone { max-width: 820px; }
}

@media (min-width: 1280px) {
  .phone { max-width: 1040px; }
}

@media (min-width: 1700px) {
  .phone { max-width: 1200px; } /* cap on ultra-wide */
}

/* Always-visible diagonal mint band at the bottom (anchored) */
.app-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 150px;
  background: var(--skoda-green-light);
  clip-path: polygon(0 55%, 100% 0%, 100% 100%, 0% 100%);
  z-index: 1;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 22px 18px;
}

.brand-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.brand-logo {
  height: 86px;
  width: auto;
  display: block;
}

@media (min-width: 640px) {
  .brand-logo { height: 120px; }
  .app-footer { height: 210px; padding-bottom: 32px; padding-right: 36px; }
  .app-header { padding: 16px 28px 8px; }
  .app-title { font-size: 22px; padding: 0 90px; }
  .app-main { padding: 12px 28px 220px; }
  .level-indicator { gap: 32px; margin-top: 10px; }
  .dot-num { width: 30px; height: 30px; font-size: 13px; }
  .dot-label { font-size: 9px; }
  .screen-title { font-size: 24px; }
  .screen-subtitle { font-size: 14px; }
  .speech { font-size: 14px; max-width: 420px; padding: 12px 18px; }
  .transformer-large { height: 400px; }
  .transformer-medium { height: 280px; }
  .five-s-grid { gap: 8px; }
  .five-s-card { padding: 6px 14px 6px 6px; }
  .five-s-letter { width: 24px; height: 24px; font-size: 13px; }
  .five-s-word { font-size: 13px; }
  .btn { font-size: 16px; padding: 14px 32px; min-width: 240px; }
  .level-tag { font-size: 10px; }
  .level-prompt { font-size: 16px; }
  .timer { font-size: 14px; padding: 6px 14px; }
  .hint { font-size: 12px; padding: 6px 14px; }
  .play-area { min-height: 380px; }
  .slot { width: 72px; height: 72px; }
  .slot-ghost { font-size: 42px; }
  .slot-tool { font-size: 38px; }
  .tool { width: 56px; height: 56px; font-size: 32px; }
  .quadrant { gap: 14px; padding: 14px; }
  .results-table { padding: 12px 18px; }
  .result-row { font-size: 14px; }
  .result-total .result-value { font-size: 18px; }
}

/* ===== Header ===== */
.app-header {
  position: relative;
  z-index: 3;
  padding: 12px 16px 6px;
  flex-shrink: 0;
}

.app-title {
  margin: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1.3px;
  color: var(--skoda-white);
  padding: 0 64px;
  line-height: 1.1;
}

.lang-switch {
  position: absolute;
  top: 10px;
  right: 14px;
  display: flex;
  gap: 2px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: var(--radius-pill);
  padding: 2px;
  z-index: 3;
}

/* Back-to-hub link in the header (top-left) */
.app-back {
  position: absolute;
  top: 10px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--skoda-white);
  background: rgba(0, 0, 0, 0.28);
  padding: 5px 11px 5px 8px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  z-index: 3;
  opacity: 0.85;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.app-back:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.42);
}

.app-back::before {
  content: "‹";
  font-size: 16px;
  line-height: 0.8;
  margin-right: 2px;
  font-weight: 800;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--skoda-white);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  opacity: 0.7;
  transition: all 0.15s ease;
}

.lang-btn.is-active {
  background: var(--skoda-green-light);
  color: var(--skoda-green-dark);
  opacity: 1;
}

.level-indicator {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-top: 8px;
}

.level-dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  opacity: 0.45;
  transition: opacity 0.2s ease;
}

.level-dot.is-active,
.level-dot.is-done { opacity: 1; }

.dot-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--skoda-green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: var(--skoda-white);
  background: transparent;
}

.level-dot.is-active .dot-num {
  background: var(--skoda-orange);
  border-color: var(--skoda-orange);
  color: var(--skoda-green-dark);
  box-shadow: 0 0 0 4px rgba(247, 169, 42, 0.18);
}

.level-dot.is-done .dot-num {
  background: var(--skoda-green-light);
  border-color: var(--skoda-green-light);
  color: var(--skoda-green-dark);
}

.dot-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--skoda-white);
}

/* ===== Main + screens ===== */
.app-main {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  padding: 8px 14px 140px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  gap: 10px;
}

.screen.is-active {
  display: flex;
  animation: fade-in 0.25s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-title {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.4px;
}

.screen-subtitle {
  margin: 0 6px;
  text-align: center;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.85);
}

/* ===== Speech bubble ===== */
.speech {
  position: relative;
  background: var(--skoda-orange);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  font-style: italic;
  line-height: 1.3;
  text-align: center;
  align-self: center;
  max-width: 280px;
  box-shadow: var(--shadow-card);
}

.speech p { margin: 0; }

.speech-top::after {
  content: "";
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--skoda-orange);
}

/* ===== Transformer ===== */
.transformer {
  display: block;
  margin: 0 auto;
  width: auto;
  height: 200px;
  max-width: 100%;
  object-fit: contain;
}

.transformer-large { height: 320px; }
.transformer-medium { height: 220px; }

/* ===== Intro 5S tags ===== */
.five-s-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 2px 4px;
}

.five-s-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 5px;
  border-radius: var(--radius-pill);
  background: var(--skoda-green-mid);
  border: 1px solid var(--skoda-green-line);
}

.five-s-letter {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--skoda-orange);
  color: var(--skoda-green-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}

.five-s-word {
  font-size: 11px;
  font-weight: 700;
  color: var(--skoda-white);
  letter-spacing: 0.3px;
  line-height: 1;
  white-space: nowrap;
}

/* ===== Buttons ===== */
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 15px;
  padding: 12px 24px;
  border-radius: 10px;
  transition: transform 0.1s ease, filter 0.15s ease;
  align-self: center;
  min-width: 200px;
  margin-top: 4px;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--skoda-green-light);
  color: var(--skoda-green-dark);
  box-shadow: var(--shadow-soft);
}

.btn-primary:hover { filter: brightness(1.05); }

/* ===== Level head ===== */
.level-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.level-head-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.level-tag {
  font-size: 9px;
  font-weight: 800;
  color: var(--skoda-orange);
  letter-spacing: 1.1px;
}

.level-prompt {
  font-size: 14px;
  font-weight: 700;
  color: var(--skoda-white);
  line-height: 1.25;
}

.timer {
  background: var(--skoda-green-mid);
  border: 1px solid var(--skoda-green-line);
  color: var(--skoda-orange);
  font-weight: 800;
  font-size: 13px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ===== Play areas ===== */
.play-area {
  flex: 1;
  border-radius: var(--radius-card);
  position: relative;
  overflow: hidden;
  min-height: 320px;
  background: var(--skoda-green-mid);
  border: 1px solid var(--skoda-green-line);
}

.play-area-chaos {
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.04) 0, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255,255,255,0.04) 0, transparent 40%),
    var(--skoda-green-mid);
}

/* Tools (chaos) */
.tool {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 11px;
  background: var(--skoda-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-card);
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.2s ease;
  border: 2px solid transparent;
  padding: 0;
}

.tool:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.32);
}

.tool.is-correct {
  background: var(--skoda-green-light);
  border-color: var(--skoda-green-light);
  animation: pop 0.35s ease-out;
}

.tool.is-wrong {
  animation: shake 0.35s ease-out;
  border-color: var(--skoda-red);
}

.tool.is-selected {
  border-color: var(--skoda-orange);
  box-shadow: 0 0 0 3px rgba(247, 169, 42, 0.35), var(--shadow-card);
}

.tool.is-faded {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.6);
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* ===== Level 2: sort layout (quadrants + bench) ===== */
.play-area-sort {
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 8px;
}

.quadrants-sort {
  flex: 0 0 55%;
  min-height: 200px;
}

.bench {
  flex: 1;
  position: relative;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.04) 0, transparent 40%),
    radial-gradient(circle at 70% 70%, rgba(255,255,255,0.04) 0, transparent 40%),
    rgba(0, 0, 0, 0.18);
  border-radius: 10px;
  min-height: 130px;
  border: 1px dashed var(--skoda-green-line);
}

/* Once sort phase is done, hide the bench but keep quadrants the same size */
.play-area-sort.is-find-phase .bench { display: none; }

/* ===== Quadrants (Level 2 + Level 3) ===== */
.quadrants {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 6px;
  padding: 0;
}

.play-area-memory {
  padding: 8px;
  display: flex;
  flex-direction: column;
}

.play-area-memory .quadrants {
  flex: 0 0 auto;
  height: 55%;
  min-height: 220px;
}

/* Memory level: silhouettes are deliberately fainter — visible but not screaming */
#level3Quadrants .slot-ghost {
  filter: brightness(0) invert(1) sepia(0.6) saturate(5) hue-rotate(80deg) opacity(0.22);
}

.quadrant {
  background: rgba(0, 0, 0, 0.22);
  border: 2px solid var(--skoda-green-line);
  border-radius: 10px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  min-height: 80px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.quadrant.is-target {
  border-color: var(--skoda-orange);
  background: rgba(247, 169, 42, 0.12);
}

.quadrant.is-correct {
  border-color: var(--skoda-green-light);
  background: rgba(159, 229, 176, 0.18);
  animation: pop 0.35s ease-out;
}

.quadrant.is-wrong {
  border-color: var(--skoda-red);
  animation: shake 0.35s ease-out;
}

/* Slot = molitan-cutout: silhouette underneath, optional tool on top */
.slot {
  position: relative;
  width: 60px;
  height: 60px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 12px;
  border: 2px dashed rgba(159, 229, 176, 0.4);
  background: rgba(0, 0, 0, 0.22);
  transition: border-color 0.15s ease, background 0.2s ease, transform 0.12s ease;
}

.slot:hover { transform: scale(1.05); }

.slot-ghost {
  font-size: 32px;
  /* brightness(0) flattens the emoji to solid black so internal details disappear;
     invert+hue tints it ŠKODA mint; opacity keeps it whisper-quiet */
  filter: brightness(0) invert(1) sepia(0.7) saturate(7) hue-rotate(80deg) opacity(0.55);
  pointer-events: none;
  user-select: none;
}

.slot-tool {
  position: absolute;
  inset: 3px;
  border-radius: 9px;
  background: var(--skoda-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  box-shadow: var(--shadow-card);
  border: 2px solid transparent;
  user-select: none;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.slot-tool.is-empty { opacity: 0; }
.slot-tool.is-hidden { opacity: 0; }

.slot.is-target {
  border-color: var(--skoda-orange);
  background: rgba(247, 169, 42, 0.18);
}

.slot.is-correct .slot-tool {
  background: var(--skoda-green-light);
  animation: pop 0.35s ease-out;
}

.slot.is-wrong {
  animation: shake 0.35s ease-out;
  border-color: var(--skoda-red);
}

/* Memory overlay */
.memory-overlay {
  position: absolute;
  inset: 8px;
  background: rgba(14, 61, 46, 0.85);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.memory-overlay.is-visible { opacity: 1; }

.countdown {
  font-size: 44px;
  color: var(--skoda-orange);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* ===== Level foot ===== */
.level-foot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.progress {
  display: flex;
  gap: 3px;
  justify-content: center;
}

.progress-cell {
  width: 16px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
}

.progress-cell.is-done { background: var(--skoda-green-light); }
.progress-cell.is-current { background: var(--skoda-orange); }

.hint {
  margin: 0;
  text-align: center;
  font-size: 11px;
  color: var(--skoda-white);
  background: rgba(0, 0, 0, 0.32);
  padding: 5px 12px;
  border-radius: 8px;
  align-self: center;
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* ===== Results ===== */
.results-table {
  background: var(--skoda-green-mid);
  border: 1px solid var(--skoda-green-line);
  border-radius: var(--radius-card);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.result-row:last-child { border-bottom: none; }

.result-label {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
}

.result-value {
  color: var(--skoda-orange);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.result-total {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 2px solid var(--skoda-green-line);
}

.result-total .result-label {
  color: var(--skoda-white);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.result-total .result-value {
  font-size: 16px;
  color: var(--skoda-green-light);
}

/* ===== Find banner (Level 2 -> find phase) ===== */
.find-banner {
  align-self: center;
  background: rgba(159, 229, 176, 0.18);
  color: var(--skoda-green-light);
  border: 1px solid rgba(159, 229, 176, 0.4);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

/* ===== Tiny screen tweaks ===== */
@media (max-height: 700px) {
  .transformer-large { width: 130px; height: 130px; }
  .transformer-medium { width: 100px; height: 100px; }
  .speech { font-size: 11px; padding: 6px 10px; }
  .five-s-grid { gap: 3px; }
  .five-s-letter { font-size: 14px; }
  .five-s-word { font-size: 7px; }
  .btn { padding: 10px 22px; font-size: 14px; }
  .play-area { min-height: 260px; }
}

@media (max-width: 360px) {
  .app-title { font-size: 15px; padding: 0 56px; }
  .level-indicator { gap: 16px; }
  .tool { width: 44px; height: 44px; font-size: 24px; }
  .qtool { width: 38px; height: 38px; font-size: 22px; }
}
