/* ============================================
   ŠKODA – 5S minihra (specifické styly)
   ============================================ */

.fives-main {
  padding: 6px 12px 140px;
  gap: 0;
}

/* Intro layout — bubble sits right above the transformer */
.screen-intro,
.screen-hub {
  align-items: center;
  gap: 0;
}

.screen-intro .speech-top,
.screen-hub .speech-top,
.screen-final .speech-top {
  margin-bottom: -10px;
  align-self: center;
  position: relative;
  z-index: 2;
}

.screen-intro .transformer-large,
.screen-intro .transformer-medium,
.screen-hub .transformer-large,
.screen-hub .transformer-medium,
.screen-final .transformer-medium {
  margin: 0 auto 8px;
}

@media (min-width: 640px) {
  .fives-main { padding: 10px 24px 200px; }
}

/* ===== Intro hub grid (4 karty 2×2) ===== */
.hub-grid--5s {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

@media (max-width: 480px) {
  .hub-grid--5s { grid-template-columns: 1fr; }
}

.hub-card.is-locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.hub-card.is-locked:hover {
  transform: none;
  border-color: var(--skoda-green-line);
  background: var(--skoda-green-mid);
}

.hub-card.is-locked .hub-card-cta {
  background: rgba(0, 0, 0, 0.25);
  color: rgba(255, 255, 255, 0.6);
  border-color: rgba(255, 255, 255, 0.1);
}

/* ===== HUD (top bar with score/time/counters) ===== */
.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--skoda-green-line);
  border-radius: 10px;
  padding: 6px 8px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}

.hud-counter {
  flex-direction: row;
  gap: 5px;
}

.hud-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
}

.hud-value {
  font-size: 14px;
  font-weight: 800;
  color: var(--skoda-white);
}

.hud-score .hud-value { color: var(--skoda-orange); }
.hud-time .hud-value { color: var(--skoda-green-light); }

.hud-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

@media (min-width: 640px) {
  .hud { padding: 8px 12px; }
  .hud-label { font-size: 9px; }
  .hud-value { font-size: 16px; }
  .hud-icon { width: 26px; height: 26px; }
}

/* ===== Play stage (work table) ===== */
.play-stage {
  position: relative;
  flex: 1;
  border-radius: var(--radius-card);
  overflow: hidden;
  border: 1px solid var(--skoda-green-line);
  min-height: 240px;
  background: #1a1a1a;
}

.stage-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.stage-objects {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.stage-zones {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Object on the table — both tools and trash share these */
.obj {
  position: absolute;
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  outline: none;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.15s ease, filter 0.15s ease;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.45));
  will-change: transform;
}

.obj:focus,
.obj:focus-visible {
  outline: none;
}

.obj img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.obj.is-selected {
  filter: drop-shadow(0 0 6px var(--skoda-orange)) drop-shadow(0 3px 5px rgba(0, 0, 0, 0.45));
  transform: scale(1.08);
  z-index: 9999 !important;
}

.obj.is-removing {
  animation: obj-leave 0.32s ease-in forwards;
  pointer-events: none;
}

@keyframes obj-leave {
  to { transform: scale(0.4) rotate(20deg); opacity: 0; }
}

.obj.is-pulse {
  animation: obj-pulse 0.9s ease-in-out infinite;
}

@keyframes obj-pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 6px var(--skoda-orange)) drop-shadow(0 3px 5px rgba(0, 0, 0, 0.45)); }
  50% { transform: scale(1.1); filter: drop-shadow(0 0 14px var(--skoda-orange)) drop-shadow(0 3px 5px rgba(0, 0, 0, 0.45)); }
}

/* Time bar overlay on the stage */
.time-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 6px;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.time-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--skoda-green-light), var(--skoda-orange));
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 0.1s linear;
}

.time-bar-fill.is-low { background: var(--skoda-red); }

/* ===== Bottom bar (Transformer, slots, targets) ===== */
.bottom-bar {
  flex-shrink: 0;
  margin-top: 6px;
  display: grid;
  gap: 5px;
}

.bottom-bar--l1 {
  grid-template-columns: 1.2fr 0.9fr 1.2fr 1fr;
  align-items: stretch;
}

.bottom-bar--l2 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}

/* L2 play area — shelf on the left, table on the right */
.play-area-l2 {
  display: flex;
  flex-direction: row;
  gap: 6px;
  flex: 1;
  min-height: 240px;
  margin-bottom: 6px;
}

@media (min-width: 640px) {
  .play-area-l2 { min-height: 380px; }
}

.shelf-vertical {
  flex: 0 0 86px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(180deg, rgba(0,0,0,0.32), rgba(0,0,0,0.18));
  border: 1px solid var(--skoda-green-line);
  border-radius: var(--radius-card);
  padding: 8px 6px;
  cursor: pointer;
  appearance: none;
  font-family: inherit;
  color: inherit;
  transition: border-color 0.15s ease;
}

.shelf-vertical:hover { border-color: var(--skoda-orange); }

@media (min-width: 640px) {
  .shelf-vertical { flex: 0 0 110px; }
}

.bottom-tile {
  position: relative;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--skoda-green-line);
  border-radius: 10px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  min-height: 140px;
  appearance: none;
  font-family: inherit;
  color: inherit;
}

button.bottom-tile {
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

button.bottom-tile:hover {
  background: rgba(0, 0, 0, 0.4);
  border-color: var(--skoda-orange);
}

.bottom-tile.is-target-active {
  border-color: var(--skoda-orange);
  background: rgba(247, 169, 42, 0.18);
  animation: tile-glow 1.1s ease-in-out infinite;
}

@keyframes tile-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(247, 169, 42, 0); }
  50% { box-shadow: 0 0 16px rgba(247, 169, 42, 0.6); }
}

.bottom-tile.is-correct {
  animation: tile-correct 0.5s ease-out;
}

.bottom-tile.is-wrong {
  animation: tile-wrong 0.42s ease-out;
}

@keyframes tile-correct {
  0% { background: rgba(0, 0, 0, 0.24); }
  40% { background: rgba(159, 229, 176, 0.5); }
  100% { background: rgba(0, 0, 0, 0.24); }
}

@keyframes tile-wrong {
  0%, 100% { transform: translateX(0); border-color: var(--skoda-red); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Transformer tile */
.bottom-tile--char {
  flex-direction: column;
  padding: 0;
  overflow: visible;
}

.bottom-tile--char img {
  width: 100%;
  height: 100%;
  max-height: 140px;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

@media (min-width: 640px) {
  .bottom-tile--char img { max-height: 180px; }
}

/* Side speech bubble — sits above the entire bottom bar so it never overflows the viewport */
.bottom-bar { position: relative; z-index: 10; }
.play-stage { isolation: isolate; }

.speech-side {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 8px;
  right: 8px;
  background: var(--skoda-orange);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  font-style: italic;
  line-height: 1.3;
  text-align: center;
  box-shadow: var(--shadow-card);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.speech-side.is-visible {
  opacity: 1;
}

/* Tail — points down toward the Transformer tile (~25% from left for L1 layout) */
.speech-side::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 22%;
  transform: translateY(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--skoda-orange);
}

/* In L2 the Transformer sits in the left tile. */
.bottom-bar--l2 .speech-side::after {
  left: 16.666%;
  transform: translateX(-50%) translateY(-50%) rotate(45deg);
}

.speech-side p {
  margin: 0;
}

@media (min-width: 640px) {
  .speech-side { font-size: 14px; padding: 10px 16px; }
}

/* Silhouette frame (level 1) */
.bottom-tile--silhouette,
.bottom-tile--hand {
  padding: 2px;
  position: relative;
}

.silhouette-frame,
.hand-frame {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--skoda-cream);
  overflow: hidden;
}

.bottom-tile--hand {
  padding: 4px;
}

.bottom-tile--hand .hand-frame {
  position: absolute;
  inset: 6px;
  background: var(--skoda-cream);
  border: 3px solid rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 2;
  overflow: hidden;
}

.silhouette-img {
  max-width: 75%;
  max-height: 75%;
  object-fit: contain;
  filter: brightness(0);
  display: block;
}

/* Color overlay that fills the silhouette bottom-up as time runs out */
.silhouette-cover {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0%;
  background: rgba(230, 57, 70, 0.55);
  pointer-events: none;
  z-index: 2;
  transition: none;
}

.silhouette-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  font-weight: 900;
  color: var(--skoda-orange);
  background: rgba(0, 0, 0, 0.6);
  z-index: 3;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  pointer-events: none;
}

.silhouette-countdown.is-visible {
  opacity: 1;
}

/* Silhouette zone-color border (level 2) */
.silhouette-frame.zone-red { box-shadow: inset 0 0 0 4px var(--skoda-red); }
.silhouette-frame.zone-green { box-shadow: inset 0 0 0 4px var(--skoda-green-light); }
.silhouette-frame.zone-blue { box-shadow: inset 0 0 0 4px #3FA9D8; }

.hand-frame.zone-red { box-shadow: inset 0 0 0 4px var(--skoda-red); }
.hand-frame.zone-green { box-shadow: inset 0 0 0 4px var(--skoda-green-light); }
.hand-frame.zone-blue { box-shadow: inset 0 0 0 4px #3FA9D8; }

/* Toolbox / bin tiles — fill the tile so the icons read big */
.bottom-tile--target {
  padding: 2px;
}

.bottom-tile--target img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Shelf with 3 slots (level 2) — pure CSS, no background image */
.bottom-tile--shelf {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 6px;
  gap: 4px;
  background: linear-gradient(180deg, rgba(0,0,0,0.32), rgba(0,0,0,0.18));
}

.shelf-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--skoda-orange);
  text-align: center;
  flex-shrink: 0;
}

.shelf-slots {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  flex: 1;
  width: 100%;
}

.shelf-slots.shelf-slots--vertical {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: flex-start;
  align-items: stretch;
}

.shelf-slots.shelf-slots--vertical .shelf-slot {
  width: 100%;
  aspect-ratio: 1;
  flex: 0 0 auto;
}

.shelf-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  border: 1.5px dashed rgba(255, 255, 255, 0.18);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.shelf-slot.is-target-active {
  background: rgba(247, 169, 42, 0.35);
  border-color: var(--skoda-orange);
  border-style: solid;
  animation: tile-glow 1.1s ease-in-out infinite;
}

.shelf-slot img {
  width: 80%;
  height: 80%;
  object-fit: contain;
  position: static;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

@media (min-width: 640px) {
  .shelf-label { font-size: 11px; }
}

/* L2 zone overlays — colored shaded regions on the empty work table */
.zone-overlay {
  position: absolute;
  border-radius: 10px;
  pointer-events: none;
  border: 2px solid;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.zone-overlay.zone-red { background-color: rgba(230, 57, 70, 0.32); border-color: var(--skoda-red); }
.zone-overlay.zone-green { background-color: rgba(159, 229, 176, 0.28); border-color: var(--skoda-green-light); }
.zone-overlay.zone-blue { background-color: rgba(63, 169, 216, 0.32); border-color: #3FA9D8; }

.zone-overlay.is-target-active {
  border-color: var(--skoda-orange);
  border-width: 4px;
  animation: tile-glow 1.1s ease-in-out infinite;
  pointer-events: none;
}

/* L2 tool slot — silhouette underneath, actual tool on top, hides when borrowed */
#l2Stage .obj-tool {
  opacity: 1;
  background: rgba(245, 241, 230, 0.85);
  border-radius: 8px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

#l2Stage .obj-tool .tool-silueta,
#l2Stage .obj-tool .tool-actual {
  position: absolute;
  inset: 4px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  object-fit: contain;
  pointer-events: none;
}

#l2Stage .obj-tool .tool-silueta {
  filter: brightness(0) opacity(0.32);
  z-index: 1;
}

#l2Stage .obj-tool .tool-actual {
  z-index: 2;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* When the tool has been "borrowed" (in transformer's hand), fade out the actual tool */
#l2Stage .obj-tool.is-borrowed .tool-actual {
  opacity: 0;
}

#l2Stage .obj-tool.is-selected {
  border-color: var(--skoda-orange);
  box-shadow: 0 0 14px rgba(247, 169, 42, 0.7), 0 4px 10px rgba(0, 0, 0, 0.4);
  z-index: 9999 !important;
}

/* Score popups */
.score-popup-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

.score-popup {
  position: absolute;
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  animation: score-float 1.05s ease-out forwards;
  letter-spacing: 0.4px;
}

.score-popup.is-positive { color: var(--skoda-green-light); }
.score-popup.is-negative { color: var(--skoda-red); }

@keyframes score-float {
  0% { transform: translate(-50%, -50%) translateY(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) translateY(-50px); opacity: 0; }
}

/* Tutorial overlay */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  pointer-events: auto;
}

.tutorial-overlay.is-visible {
  display: block;
}

.tutorial-spotlight {
  position: absolute;
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6),
              0 0 20px rgba(247, 169, 42, 0.7),
              inset 0 0 0 3px var(--skoda-orange);
  pointer-events: none;
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}

.tutorial-bubble {
  position: absolute;
  background: var(--skoda-orange);
  color: var(--ink);
  padding: 14px 18px;
  border-radius: 14px;
  font-weight: 700;
  font-style: italic;
  line-height: 1.35;
  max-width: 320px;
  box-shadow: var(--shadow-card);
  font-size: 14px;
}

.tutorial-bubble p {
  margin: 0 0 10px;
}

.tutorial-bubble .btn {
  font-size: 12px;
  padding: 8px 16px;
  min-width: 0;
}

/* Final screen badges */
.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 6px 0;
}

.badge-item {
  width: 64px;
  height: 64px;
  position: relative;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
}

.badge-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.badge-item.is-locked {
  opacity: 0.25;
  filter: grayscale(1) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
}

.badge-item.is-earned {
  animation: badge-pop 0.7s ease-out;
}

@keyframes badge-pop {
  0% { transform: scale(0.4) rotate(-15deg); opacity: 0; }
  60% { transform: scale(1.18) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@media (min-width: 640px) {
  .badge-item { width: 84px; height: 84px; }
  .play-stage { min-height: 380px; }
  .bottom-tile { min-height: 180px; }
}

/* Skip button on tutorial */
.tutorial-skip {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(0, 0, 0, 0.5);
  color: var(--skoda-white);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.btn-small {
  font-size: 12px !important;
  padding: 8px 16px !important;
  min-width: 0 !important;
}

/* Initial loading screen overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--skoda-green-dark);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
}

.loading-bar {
  width: 220px;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  background: var(--skoda-orange);
  width: 0%;
  transition: width 0.2s ease;
}
