/* Korner Blocks 2.5D: HUD, screens and pop-ups over the 3D canvas. --ui scales the type with the box. */
.kb {
  --ui: 1;
  --cell: 30px;
  --ink: #2a1d5c;
  --glass: rgba(24, 16, 64, 0.26);
  --edge: rgba(255, 255, 255, 0.42);
  position: absolute;
  inset: 0;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: linear-gradient(180deg, #3f8ff0, #e4f4ff);
  opacity: 0;
  transition: opacity 0.5s ease;
}
.kb.ready { opacity: 1; }
.kb.kb-playing { touch-action: none; }
.kb-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.kb button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.kb svg { width: 1.15em; height: 1.15em; flex: none; }

/* ------------------------------------------------ HUD */
.kb-hud { position: absolute; inset: 0; pointer-events: none; transition: opacity 0.4s ease; }
.kb-hud.kb-off { opacity: 0; }
.kb-hud.kb-off * { pointer-events: none !important; }
.kb-label {
  font-size: calc(11px * var(--ui));
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 1px 2px rgba(20, 10, 60, 0.45);
}
.kb-slot {
  position: absolute;
  border-radius: calc(18px * var(--ui));
  background: var(--glass);
  border: 2px solid var(--edge);
  box-shadow: inset 0 2px 10px rgba(255, 255, 255, 0.18), 0 8px 24px rgba(20, 10, 60, 0.18);
}
.kb-slot .kb-label { position: absolute; left: 50%; top: calc(6px * var(--ui)); transform: translateX(-50%); }
.kb-slot.kb-small { border-radius: calc(14px * var(--ui)); border-width: 1.5px; background: rgba(24, 16, 64, 0.18); }
.kb-hold { pointer-events: auto; cursor: pointer; }
.kb-hold:active { transform: scale(0.97); }

.kb-stats { position: absolute; display: flex; flex-direction: column; gap: calc(10px * var(--ui)); }
.kb-stat {
  border-radius: calc(16px * var(--ui));
  background: var(--glass);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  padding: calc(8px * var(--ui)) calc(12px * var(--ui));
  display: flex;
  flex-direction: column;
  align-items: center;
}
.kb-stat b {
  font-family: 'Fredoka One', 'Inter', sans-serif;
  font-weight: 400;
  font-size: calc(24px * var(--ui));
  line-height: 1.1;
  text-shadow: 0 2px 0 rgba(42, 29, 92, 0.35), 0 3px 10px rgba(20, 10, 60, 0.3);
  font-variant-numeric: tabular-nums;
}
.kb-stat.kb-score b { font-size: calc(30px * var(--ui)); }
.kb-timer { display: none !important; }
.kb-rush .kb-timer { display: flex !important; }
.kb-tools { position: absolute; display: flex; justify-content: flex-end; align-items: flex-end; gap: 8px; }
.kb-icon {
  pointer-events: auto;
  width: calc(46px * var(--ui));
  height: calc(46px * var(--ui));
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--glass) !important;
  border: 2px solid var(--edge) !important;
  font-size: calc(20px * var(--ui)) !important;
  box-shadow: 0 6px 16px rgba(20, 10, 60, 0.2);
}
.kb-icon:active { transform: scale(0.94); }

/* phone held upright: a bar along the top */
.kb-tall .kb-stats { flex-direction: row; flex-wrap: wrap; gap: 4px; align-content: center; justify-content: center; }
.kb-tall .kb-stat { padding: 3px 6px; border-radius: 12px; flex: 1 1 28%; min-width: 0; }
.kb-tall .kb-stat .kb-label { font-size: 9px; letter-spacing: 0.08em; }
.kb-tall .kb-stat b { font-size: 16px; }
.kb-tall .kb-stat.kb-score { flex: 1 1 100%; }
.kb-tall .kb-stat.kb-score b { font-size: 22px; }
.kb-tall .kb-stat.kb-score .kb-label { display: none; }
.kb-tall.kb-rush .kb-stat:nth-child(2) { display: none; }
.kb-tall .kb-slot .kb-label { font-size: 9px; top: 3px; }
.kb-tall .kb-icon { width: 40px; height: 40px; font-size: 18px !important; }

/* stack nearly at the top */
.kb-danger { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.5s; box-shadow: inset 0 0 calc(var(--cell) * 3) rgba(255, 50, 80, 0.55); }
.kb-danger-on .kb-danger { opacity: 1; animation: kb-pulse 0.9s ease-in-out infinite alternate; }
@keyframes kb-pulse { from { opacity: 0.45; } to { opacity: 1; } }

/* ------------------------------------------------ pop-ups */
.kb-pops { position: absolute; inset: 0; pointer-events: none; }
.kb-pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'Fredoka One', 'Inter', sans-serif;
  font-size: calc(var(--cell) * 1.15);
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 3px 0 #6b46e8, 0 5px 14px rgba(40, 10, 90, 0.5);
  animation: kb-pop 1.4s cubic-bezier(.2, .9, .3, 1.2) both;
}
.kb-pop.big { font-size: calc(var(--cell) * 1.8); color: #fff6b0; text-shadow: 0 3px 0 #ff5d73, 0 0 22px rgba(255, 220, 120, 0.8); }
.kb-pop.pts { font-size: calc(var(--cell) * 0.85); color: #fff0a8; }
.kb-pop.combo { font-size: calc(var(--cell) * 0.8); color: #b9fff3; text-shadow: 0 2px 0 #1b8f86, 0 4px 12px rgba(0, 60, 60, 0.45); }
@keyframes kb-pop {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.4); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  25% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(0.95); }
}

.kb-banner {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.kb-banner b { display: block; font-family: 'Fredoka One', sans-serif; font-weight: 400; font-size: calc(46px * var(--ui)); text-shadow: 0 4px 0 #6b46e8, 0 8px 22px rgba(30, 10, 80, 0.5); }
.kb-banner span { display: inline-block; margin-top: 4px; padding: 4px 14px; border-radius: 99px; background: rgba(255, 255, 255, 0.9); color: var(--ink); font-weight: 800; font-size: calc(14px * var(--ui)); letter-spacing: 0.06em; text-transform: uppercase; }
.kb-banner.go { animation: kb-banner 2.2s ease both; }
@keyframes kb-banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  20% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -70%); }
}

.kb-hint {
  position: absolute;
  left: 50%;
  bottom: 3%;
  transform: translate(-50%, 20px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: min(94%, 640px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.kb-hint.in { opacity: 1; transform: translate(-50%, 0); }
.kb-hint span { padding: 6px 12px; border-radius: 99px; background: rgba(255, 255, 255, 0.92); color: var(--ink); font-weight: 700; font-size: calc(13px * var(--ui)); box-shadow: 0 4px 14px rgba(20, 10, 60, 0.25); }

/* ------------------------------------------------ screens */
.kb-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(20, 12, 60, 0.18), rgba(20, 12, 60, 0.5));
  animation: kb-fade 0.3s ease both;
  overflow-y: auto;
}
.kb-screen[hidden] { display: none; }
.kb-title { background: radial-gradient(ellipse at center, rgba(20, 12, 60, 0.05), rgba(20, 12, 60, 0.32)); }
@keyframes kb-fade { from { opacity: 0; } to { opacity: 1; } }
.kb-card {
  position: relative;
  width: min(440px, 100%);
  padding: calc(26px * var(--ui)) calc(26px * var(--ui)) calc(22px * var(--ui));
  border-radius: 26px;
  text-align: center;
  background: linear-gradient(160deg, rgba(139, 92, 246, 0.94), rgba(79, 70, 229, 0.94) 60%, rgba(59, 130, 246, 0.94));
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 24px 60px rgba(20, 10, 60, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.3);
  animation: kb-rise 0.45s cubic-bezier(.2, .9, .3, 1.15) both;
}
@keyframes kb-rise { from { opacity: 0; transform: translateY(24px) scale(0.94); } to { opacity: 1; transform: none; } }
.kb-card h2 { font-family: 'Fredoka One', sans-serif; font-weight: 400; font-size: calc(34px * var(--ui)); margin-bottom: 14px; text-shadow: 0 3px 0 rgba(42, 29, 92, 0.4); }
.kb-card h3 { font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 6px; color: #fff4c2; }
.kb-logo {
  font-family: 'Fredoka One', sans-serif;
  font-weight: 400;
  font-size: calc(46px * var(--ui));
  line-height: 1.02;
  position: relative;
  display: inline-block;
  text-shadow: 0 4px 0 rgba(42, 29, 92, 0.45), 0 10px 24px rgba(20, 10, 60, 0.35);
}
.kb-logo-a { color: #ff7b8a; }
.kb-logo-b { color: #5ce1d6; }
.kb-logo i {
  position: absolute;
  right: -14px;
  top: -16px;
  font-style: normal;
  font-family: 'Inter', sans-serif;
  font-weight: 900;
  font-size: calc(15px * var(--ui));
  padding: 3px 9px;
  border-radius: 99px;
  color: var(--ink);
  background: #ffd84d;
  transform: rotate(10deg);
  box-shadow: 0 3px 0 #c99a12;
  text-shadow: none;
}
.kb-tag { margin: 8px 0 18px; font-weight: 600; color: rgba(255, 255, 255, 0.9); font-size: calc(15px * var(--ui)); }
.kb-modes { display: flex; flex-direction: column; gap: 10px; margin: 0 auto; max-width: 320px; }
.kb-modes.kb-two { flex-direction: row; max-width: none; margin-top: 18px; }
.kb-modes.kb-two .kb-btn { flex: 1; }
.kb-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 18px !important;
  border-radius: 16px !important;
  font-weight: 800 !important;
  font-size: calc(18px * var(--ui)) !important;
  color: var(--ink) !important;
  background: #fff !important;
  box-shadow: 0 5px 0 #c9bdf5, 0 10px 20px rgba(20, 10, 60, 0.25);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  position: relative;
}
.kb-btn small { font-weight: 700; font-size: 12px; opacity: 0.7; margin-left: auto; }
.kb-btn span { white-space: nowrap; }
.kb-btn small:empty { display: none; }
.kb-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #c9bdf5, 0 4px 10px rgba(20, 10, 60, 0.25); }
.kb-btn-main { background: linear-gradient(180deg, #ffe066, #ffc531) !important; box-shadow: 0 5px 0 #d1931a, 0 10px 20px rgba(20, 10, 60, 0.25); }
.kb-btn-main:active { box-shadow: 0 1px 0 #d1931a; }
.kb-btn-calm { background: linear-gradient(180deg, #8ff0e6, #2ec9bb) !important; box-shadow: 0 5px 0 #17958a, 0 10px 20px rgba(20, 10, 60, 0.25); }
.kb-btn-calm:active { box-shadow: 0 1px 0 #17958a; }
.kb-btn-rush { background: linear-gradient(180deg, #ffa3b0, #ff5d73) !important; color: #fff !important; box-shadow: 0 5px 0 #c73a52, 0 10px 20px rgba(20, 10, 60, 0.25); }
.kb-btn-rush:active { box-shadow: 0 1px 0 #c73a52; }
.kb-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.kb-chip {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  padding: 8px 12px !important;
  border-radius: 99px !important;
  font-weight: 700 !important;
  font-size: 13px !important;
  background: rgba(255, 255, 255, 0.16) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.35) !important;
}
.kb-toggle { opacity: 0.6; }
.kb-toggle.on { opacity: 1; background: rgba(255, 255, 255, 0.3) !important; }
.kb-toggle:not(.on) span { text-decoration: line-through; }

.kb-final { font-family: 'Fredoka One', sans-serif; font-size: calc(52px * var(--ui)); line-height: 1; margin: -4px 0 14px; color: #fff4b8; text-shadow: 0 4px 0 rgba(42, 29, 92, 0.45); }
.kb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kb-grid div { background: rgba(255, 255, 255, 0.14); border-radius: 14px; padding: 8px 6px; display: flex; flex-direction: column; }
.kb-grid b { font-family: 'Fredoka One', sans-serif; font-weight: 400; font-size: 22px; }
.kb-ribbon {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  padding: 6px 18px;
  border-radius: 10px;
  background: #ff5d73;
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 0 #c73a52;
  animation: kb-wobble 1.2s ease-in-out infinite alternate;
}
@keyframes kb-wobble { to { transform: translateX(-50%) rotate(3deg) scale(1.05); } }

.kb-help-card { width: min(560px, 100%); text-align: left; }
.kb-help-card h2 { text-align: center; }
.kb-help-card p { font-size: 15px; line-height: 1.5; margin-bottom: 12px; }
.kb-help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 8px 0 10px; }
.kb-help-cols > div { background: rgba(255, 255, 255, 0.12); border-radius: 16px; padding: 12px 14px; }
.kb-help-cols ul { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.kb-small-print { font-size: 13px !important; opacity: 0.85; }
@media (max-width: 520px) {
  .kb-help-cols { grid-template-columns: 1fr; }
  .kb-card { padding: 20px 16px 18px; border-radius: 22px; }
  .kb-logo { font-size: 38px; }
  .kb-logo i { right: -8px; top: -14px; font-size: 13px; }
  .kb-row { gap: 6px; }
  .kb-chip { padding: 7px 10px !important; font-size: 12px !important; }
}
@media (max-height: 520px) {
  .kb-card { padding: 14px 18px; }
  .kb-logo { font-size: 32px; }
  .kb-tag { margin: 4px 0 10px; }
  .kb-modes { gap: 6px; }
  .kb-btn { min-height: 42px; font-size: 16px !important; }
  .kb-row { margin-top: 10px; }
  .kb-card h2 { font-size: 26px; margin-bottom: 8px; }
  .kb-final { font-size: 40px; margin-bottom: 8px; }
}

.kb-nogl-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; font-weight: 700; font-size: 18px; }

/* ------------------------------------------------ the page around it: a phone held sideways fills the screen */
html.kb-immersive, html.kb-immersive body { overflow: hidden !important; overscroll-behavior: none; }
html.kb-immersive .game-container-wrapper {
  position: fixed !important;
  inset: 0;
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  max-height: none !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  margin: 0 !important;
  border-radius: 0 !important;
  z-index: 20000;
}
