/* Bieg po Tartę: one layout for the play surface and its three screen states. */
.arcade-index.game-is-open {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #050d1c;
}

.arcade-index.game-is-open .page-shell {
  width: min(1440px, 100%);
  height: 100%;
  min-height: 0;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.arcade-index.game-is-open .topbar {
  flex: 0 0 56px;
  min-height: 56px;
  padding: 0 0 10px;
  gap: 12px;
}

.arcade-index.game-is-open .brand { display: none; }
.arcade-index.game-is-open .topbar-actions { gap: 8px; }
.arcade-index.game-is-open .icon-button,
.arcade-index.game-is-open .back-button {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: #ffffff0a;
  color: #dce6ef;
  font-size: 12px;
  letter-spacing: .045em;
}

.arcade-index.game-is-open .icon-button:disabled { opacity: .35; cursor: default; }
.arcade-index.game-is-open main { display: flex; flex: 1; min-height: 0; }

#gameView {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  isolation: isolate;
}

#gameStage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  aspect-ratio: auto;
  border: 0;
  border-radius: 14px;
  background: #0b2844;
  box-shadow: none;
}

#gameStage::before { display: none; }
#gameCanvas { position: absolute; inset: 0; touch-action: none; }

#gameView .hud { top: 18px; left: 20px; right: 20px; gap: 8px; }
#gameView .hud-item {
  gap: 8px;
  min-height: 46px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: #051225cc;
  box-shadow: none;
  backdrop-filter: none;
}
#gameView .hud-item span { font-size: 12px; letter-spacing: .08em; color: #afc5d7; }
#gameView .hud-item strong { font-size: 22px; letter-spacing: .025em; }
#gameView .mini-can { width: 17px; height: 27px; }
#gameView[data-state="ready"] .hud,
#gameView[data-state="over"] .hud { visibility: hidden; }

#gameView .action-hint {
  top: 82px;
  bottom: auto;
  padding: 6px 12px 6px 6px;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  background: #07192eea;
  box-shadow: none;
}
#gameView .action-hint span { width: 26px; height: 26px; font-size: 22px; }
#gameView .action-hint b { font-size: 14px; letter-spacing: .04em; }
#gameView .action-hint.is-urgent { background: #a02b35; }

#gameView .overlay {
  z-index: 8;
  inset: 0;
  justify-items: center;
  place-items: center;
  padding: 32px;
  overflow: auto;
  border-radius: 14px;
  touch-action: pan-y;
}

#gameView #startOverlay {
  background: linear-gradient(110deg, #03132355 0%, #05142ddd 55%, #051022f5 100%);
  padding: 32px;
}

#gameView .intro-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  align-content: center;
  align-items: end;
  column-gap: 40px;
  width: min(1060px, 100%);
  height: min(620px, 100%);
  margin: 0;
  padding: 0;
  text-align: left;
}

#gameView .tarta-intro-heading { grid-column: 2; grid-row: 1; padding-bottom: 28px; z-index: 1; }
#gameView .intro-card h1 {
  margin: 0;
  font-size: clamp(64px, 7.6vw, 110px);
  line-height: .86;
  letter-spacing: -.025em;
  text-shadow: 3px 5px 0 #020d1b70;
}
#gameView .intro-card h1 span { font-size: 1.05em; letter-spacing: .02em; transform: none; }
#gameView .lead { max-width: 420px; margin: 24px 0 0; color: #d5e3ed; font-size: 16px; font-weight: 500; line-height: 1.5; }
#gameView .tarta-intro-runner {
  grid-column: 1;
  grid-row: 1 / 3;
  justify-self: center;
  align-self: end;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 18px 16px #0006);
  pointer-events: none;
}
#gameView .tarta-intro-bottom { grid-column: 2; grid-row: 2; width: 100%; z-index: 1; }
#gameView .tarta-gestures { display: none; }
#gameView .key-guide { margin: 0 0 22px; gap: 20px; }
#gameView .key-guide span { font-size: 12px; color: #adc1d2; }

#gameView .primary-button {
  width: 100%;
  min-height: 58px;
  margin: 0;
  border: 0;
  border-radius: 8px;
  color: #071121;
  background: #ffd52c;
  box-shadow: 0 4px 0 #b88416;
  font: 900 15px/1.2 Arial, sans-serif;
  letter-spacing: .075em;
  touch-action: manipulation;
}
#gameView .primary-button span { padding: 14px 12px; }
#gameView .primary-button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 5px 0 #b88416; }
#gameView .primary-button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #b88416; }

#gameView #gameOverOverlay,
#gameView #pauseOverlay { background: #020a19d9; backdrop-filter: blur(5px); }
#gameView .result-card,
#gameView .pause-card {
  width: min(460px, 100%);
  height: auto;
  margin: auto;
  padding: 32px;
  border: 0;
  border-radius: 14px;
  background: #0a1b30;
  box-shadow: 0 24px 64px #0005;
  text-align: center;
}
#gameView .result-card::before { display: none; }
#gameView .result-status { margin: 0 0 14px; }
#gameView .result-status p { font-size: 12px; letter-spacing: .16em; }
#gameView .result-status span { width: 24px; height: 24px; font-size: 20px; }
#gameView .result-card h2,
#gameView .pause-card h2 { margin: 0 0 24px; font-size: clamp(40px, 5.3vw, 60px); line-height: 1; letter-spacing: -.01em; text-shadow: 3px 4px 0 #6e1c2c; }
#gameView .result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; margin: 0 0 28px; }
#gameView .result-grid span { padding: 16px 0 0; border: 0; border-radius: 0; color: #a5b9cc; background: none; font-size: 12px; letter-spacing: .07em; }
#gameView .result-grid b { margin: 0; font-size: 26px; letter-spacing: .015em; }
#gameView .result-grid .result-main-score { grid-column: 1 / -1; padding: 6px 0 22px; border-bottom: 1px solid #b0c8dd22; }
#gameView .result-main-score b { color: #ffd52c; font-size: clamp(50px, 6vw, 72px); font-weight: 900; line-height: 1; letter-spacing: -.045em; }
#gameView .result-grid span:nth-child(2) b { color: #fff; }
#gameView .restart-hint { margin: 18px 0 0; font-size: 12px; }

#gameView .mobile-controls { z-index: 5; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0 0; }
#gameView .mobile-controls button { min-height: 74px; padding: 10px; gap: 12px; border: 0; border-radius: 10px; background: #16314e; box-shadow: none; }
#gameView .mobile-controls button:last-child { background: #ffd52c; }
#gameView .mobile-controls b { font: 900 15px/1.2 Arial, sans-serif; letter-spacing: .04em; }
#gameView .mobile-controls small { margin-top: 5px; font-size: 12px; letter-spacing: .03em; }
#gameView .mobile-controls .control-icon { font-size: 30px; }
#gameView .mobile-controls .is-active { transform: translateY(2px); filter: brightness(1.16); }
#gameView .mobile-controls .is-suggested { outline: 2px solid #f6f0c8; outline-offset: -4px; }
#gameView:not([data-state="running"]) .mobile-controls { visibility: hidden; pointer-events: none; }

@media (pointer: coarse), (max-width: 900px) {
  #gameView .mobile-controls { display: grid; }
  #gameView .key-guide { display: none; }
  #gameView .tarta-gestures { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
  #gameView .tarta-gestures span { display: grid; gap: 5px; }
  #gameView .tarta-gestures b { font-size: 14px; color: #f0f5f8; }
  #gameView .tarta-gestures small { color: #afc5d7; font-size: 12px; }
  #gameView .restart-hint { display: none; }
}

@media (max-width: 900px) and (orientation: portrait) {
  .arcade-index.game-is-open .page-shell { padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .arcade-index.game-is-open .topbar { flex: 0 0 54px; min-height: 54px; padding-bottom: 10px; }
  .arcade-index.game-is-open .record-label { display: none; }
  .arcade-index.game-is-open .back-button { min-width: 44px; padding: 0 12px; font-size: 18px; }
  .arcade-index.game-is-open .back-button span { display: none; }
  #gameView .hud { top: 14px; left: 12px; right: 12px; gap: 6px; }
  #gameView .hud-item { min-height: 42px; padding: 8px; gap: 6px; }
  #gameView .hud-item strong { font-size: 18px; }
  #gameView .score-block { flex-direction: column; align-items: flex-start; gap: 2px; min-width: 90px; }
  #gameView .speed-block { flex-direction: column; align-items: flex-end; gap: 2px; }
  #gameView .can-block { align-self: flex-start; }
  #gameView .action-hint { top: 92px; }
  #gameView #startOverlay { padding: 24px 22px 14px; background: linear-gradient(180deg, #05162df0 0%, #071c3350 55%, #051324fa 89%); }
  #gameView .intro-card { display: grid; grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto; gap: 12px; width: min(460px, 100%); height: 100%; padding: 0; }
  #gameView .tarta-intro-heading { grid-column: 1; grid-row: 1; padding: 0; text-align: center; }
  #gameView .intro-card h1 { font-size: clamp(56px, 16vw, 82px); line-height: .88; }
  #gameView .lead { margin: 18px auto 0; font-size: 16px; line-height: 1.4; }
  #gameView .tarta-intro-runner { grid-column: 1; grid-row: 2; width: 100%; max-width: 270px; height: 100%; object-position: center; }
  #gameView .tarta-intro-bottom { grid-column: 1; grid-row: 3; }
  #gameView .primary-button { min-height: 56px; font-size: 14px; }
  #gameView .overlay { padding: 20px; }
  #gameView .result-card,
  #gameView .pause-card { padding: 28px 22px 24px; }
  #gameView .result-card h2,
  #gameView .pause-card h2 { font-size: clamp(38px, 11vw, 54px); }
  #gameView .result-main-score b { font-size: 64px; }
}

@media (max-width: 900px) and (max-height: 700px) and (orientation: portrait) {
  #gameView #startOverlay { padding: 16px 18px 10px; }
  #gameView .intro-card { gap: 8px; }
  #gameView .intro-card h1 { font-size: 52px; }
  #gameView .lead { margin-top: 12px; font-size: 14px; }
  #gameView .tarta-gestures { margin-bottom: 14px; }
  #gameView .mobile-controls button { min-height: 66px; }
  #gameView .result-card { padding: 24px 18px; }
}

@media (max-height: 540px) and (orientation: landscape) {
  .arcade-index.game-is-open .page-shell { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .arcade-index.game-is-open .topbar { flex-basis: 48px; min-height: 48px; padding-bottom: 4px; }
  #gameView .mobile-controls { position: absolute; bottom: 10px; left: 12px; right: 12px; display: flex; justify-content: space-between; margin: 0; pointer-events: none; }
  #gameView .mobile-controls button { min-width: 145px; min-height: 52px; pointer-events: auto; background: #16314ef2; }
  #gameView .mobile-controls small { display: none; }
  #gameView .hud { top: 10px; }
  #gameView .action-hint { top: 65px; }
  #gameView #startOverlay { padding: 14px 28px; }
  #gameView .intro-card { column-gap: 24px; grid-template-columns: .8fr 1.2fr; }
  #gameView .tarta-intro-heading { padding-bottom: 12px; }
  #gameView .intro-card h1 { font-size: 50px; }
  #gameView .lead { margin-top: 12px; font-size: 14px; }
  #gameView .tarta-gestures,
  #gameView .key-guide { display: none; }
  #gameView .primary-button { min-height: 46px; font-size: 13px; }
  #gameView .overlay { padding: 12px; }
  #gameView .result-card { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; align-items: center; width: min(650px, 100%); padding: 20px; }
  #gameView .result-status { grid-column: 1; margin: 0; }
  #gameView .result-card h2 { grid-column: 1; margin: 0; font-size: 42px; }
  #gameView .result-grid { grid-column: 2; grid-row: 1 / 3; margin: 0; }
  #gameView .result-grid .result-main-score { padding-bottom: 10px; }
  #gameView .result-main-score b { font-size: 46px; }
  #gameView .result-grid span { padding-top: 8px; }
  #gameView .result-card .primary-button { grid-column: 1 / -1; }
  #gameView .restart-hint { display: none; }
}
