/* ============================================================
   KiezQuiz — Tablet layout
   Breakpoint: 768px – 1024px
   Bearbeite NUR diese Datei für Tablet-Layout.
   Siehe src/styles/device/README.md
   ============================================================ */

@media (min-width: 768px) and (max-width: 1024px) {
  /* from mobile.css */
    .app-shell.kq.view-city,
    .app-shell.kq:has(#city-view:not([hidden])) {
      overflow-x: hidden;
      overflow-y: auto;
      height: 100dvh;
      max-height: 100dvh;
      -webkit-overflow-scrolling: touch;
    }

    .app-shell.kq.view-city .app-footer,
    .app-shell.kq:has(#city-view:not([hidden])) .app-footer {
      display: none;
    }

    .app-shell.kq.view-city .city-view-root,
    .app-shell.kq:has(#city-view:not([hidden])) .city-view-root {
      flex: 1 0 auto;
      display: flex;
      flex-direction: column;
      min-height: 0;
      overflow: visible;
    }

    .app-shell.kq.view-city .city-view-root .app-container,
    .app-shell.kq:has(#city-view:not([hidden])) .city-view-root .app-container {
      flex: 1 0 auto;
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: visible;
      width: 100%;
      max-width: 100%;
    }

    /* DOM: console then map — flex order puts map on top (CI mockup) */
    .app-shell.kq.view-city .dashboard-grid,
    .app-shell.kq:has(#city-view:not([hidden])) .dashboard-grid,
    #city-view:not([hidden]) .dashboard-grid {
      display: flex !important;
      flex-direction: column !important;
      flex: 1 0 auto;
      min-height: 0;
      width: 100%;
      max-width: 100%;
      gap: 0;
      grid-template-columns: none !important;
      grid-template-rows: none !important;
      align-items: stretch;
    }

    .app-shell.kq.view-city .map-panel,
    .app-shell.kq:has(#city-view:not([hidden])) .map-panel,
    #city-view:not([hidden]) .map-panel {
      order: 1;
      flex: 0 0 auto;
      width: 100%;
      max-width: 100%;
      min-width: 0;
      min-height: 0;
      max-height: none;
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: minmax(0, 1fr);
      grid-template-areas: "mapstack";
      overflow: visible;
      position: relative;
    }

    .app-shell.kq.view-city .map-topbar,
    .app-shell.kq:has(#city-view:not([hidden])) .map-topbar {
      display: contents;
    }

    .app-shell.kq.view-city .map-center-btn,
    .app-shell.kq:has(#city-view:not([hidden])) .map-center-btn {
      grid-area: mapstack;
      align-self: start;
      justify-self: start;
      z-index: 36;
      margin: 8px 0 0 max(14px, env(safe-area-inset-left));
      box-shadow: var(--shadow);
    }

    .app-shell.kq.view-city .map-island-dock,
    .app-shell.kq:has(#city-view:not([hidden])) .map-island-dock {
      grid-area: mapstack;
      align-self: start;
      justify-self: end;
      position: relative;
      z-index: 35;
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      align-items: stretch;
      gap: 8px;
      width: auto;
      max-width: min(calc(100% - 120px), 72vw);
      margin: 8px max(10px, env(safe-area-inset-right)) 0 0;
      padding: 6px 8px 2px;
      overflow-x: auto;
      overflow-y: hidden;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
    }

    .app-shell.kq.view-city .map-island-dock:not(:has(.island-overlay:not([hidden]), .europe-island-overlay:not([hidden]), .islands-stack:not([hidden]))),
    .app-shell.kq:has(#city-view:not([hidden])) .map-island-dock:not(:has(.island-overlay:not([hidden]), .europe-island-overlay:not([hidden]), .islands-stack:not([hidden]))) {
      display: none;
    }

    .app-shell.kq.view-city .map-island-dock::after,
    .app-shell.kq:has(#city-view:not([hidden])) .map-island-dock::after {
      content: '';
      position: absolute;
      top: 0;
      right: 0;
      width: 36px;
      height: 100%;
      pointer-events: none;
      z-index: 2;
      background: linear-gradient(
        to left,
        var(--bg) 0%,
        color-mix(in srgb, var(--bg) 88%, transparent) 45%,
        transparent 100%
      );
    }

    .app-shell.kq.view-city .map-island-dock .island-overlay,
    .app-shell.kq.view-city .map-island-dock .islands-stack,
    .app-shell.kq:has(#city-view:not([hidden])) .map-island-dock .islands-stack {
      position: static;
      display: contents;
    }

    .app-shell.kq.view-city .map-island-dock .island-overlay,
    .app-shell.kq.view-city .map-island-dock .europe-island-overlay,
    .app-shell.kq:has(#city-view:not([hidden])) .map-island-dock .island-overlay,
    .app-shell.kq:has(#city-view:not([hidden])) .map-island-dock .europe-island-overlay {
      flex: 0 0 auto;
      white-space: nowrap;
      max-width: none;
    }

    .app-shell.kq.view-city .map-container-wrapper,
    .app-shell.kq:has(#city-view:not([hidden])) .map-container-wrapper,
    #city-view:not([hidden]) .map-container-wrapper {
      grid-area: mapstack;
      z-index: 1;
      width: auto;
      margin: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
      height: min(48vh, 48dvh);
      min-height: min(260px, 42dvh);
      max-height: min(420px, 56dvh);
      border-radius: var(--radius);
      border: 1px solid var(--line);
      overflow: hidden;
      box-shadow: var(--shadow);
    }

    .app-shell.kq.view-city .map-panel > .europe-microstates-bar,
    .app-shell.kq.view-city .map-microstates-dock,
    .app-shell.kq:has(#city-view:not([hidden])) .map-microstates-dock {
      grid-area: mapstack;
      align-self: end;
      justify-self: stretch;
      z-index: 34;
      position: relative;
      left: auto;
      right: auto;
      bottom: auto;
      width: auto;
      margin: 0 max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
      pointer-events: auto;
    }

    .app-shell.kq.view-city .map-microstates-dock::after,
    .app-shell.kq:has(#city-view:not([hidden])) .map-microstates-dock::after {
      content: '';
      position: absolute;
      top: 0;
      right: 0;
      width: 36px;
      height: 100%;
      pointer-events: none;
      z-index: 2;
      background: linear-gradient(
        to left,
        var(--bg) 0%,
        color-mix(in srgb, var(--bg) 88%, transparent) 45%,
        transparent 100%
      );
    }

    .app-shell.kq.view-city .map-controls,
    .app-shell.kq:has(#city-view:not([hidden])) .map-controls {
      grid-area: mapstack;
      align-self: end;
      justify-self: end;
      position: static;
      z-index: 40;
      margin: 0 max(10px, env(safe-area-inset-right)) 10px 0;
    }

    body.in-round .app-shell.kq.view-city .map-controls,
    body.in-round .app-shell.kq:has(#city-view:not([hidden])) .map-controls,
    body.map-play-active .app-shell.kq.view-city .map-controls,
    body.map-play-active .app-shell.kq:has(#city-view:not([hidden])) .map-controls {
      margin-bottom: calc(50px + env(safe-area-inset-bottom, 0px));
    }

    body:not(.map-play-active) .app-shell.kq.view-city .map-panel:has(.map-microstates-dock:not([hidden])) .map-controls,
    body:not(.map-play-active) .app-shell.kq:has(#city-view:not([hidden])) .map-panel:has(.map-microstates-dock:not([hidden])) .map-controls {
      margin-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }

    .app-shell.kq.view-city .console-panel,
    .app-shell.kq:has(#city-view:not([hidden])) .console-panel,
    #city-view:not([hidden]) .console-panel {
      order: 2;
      flex: 1 0 auto;
      width: 100%;
      max-width: 100%;
      min-width: 0;
      max-height: none;
      overflow: visible;
      border-right: none;
      border-top: none;
      padding: 12px max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
      gap: 14px;
    }

    .app-shell.kq.view-city .map-prompt-bar,
    .app-shell.kq:has(#city-view:not([hidden])) .map-prompt-bar {
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      align-items: center;
      gap: 8px;
      padding: 6px 10px;
      text-align: left;
    }

    .app-shell.kq.view-city .map-prompt-bar .map-prompt-title,
    .app-shell.kq:has(#city-view:not([hidden])) .map-prompt-bar .map-prompt-title {
      margin: 0;
      flex: 0 0 auto;
      font-size: 8px;
      letter-spacing: 0.06em;
      max-width: 34%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .app-shell.kq.view-city .map-prompt-bar .map-prompt-target,
    .app-shell.kq:has(#city-view:not([hidden])) .map-prompt-bar .map-prompt-target {
      flex: 1 1 auto;
      min-width: 0;
      line-height: 1.15;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .app-shell.kq.view-city .map-prompt-bar .map-prompt-sub,
    .app-shell.kq:has(#city-view:not([hidden])) .map-prompt-bar .map-prompt-sub {
      display: none;
    }

    .app-shell.kq.view-city .segment-selector,
    .app-shell.kq:has(#city-view:not([hidden])) .segment-selector {
      order: 1;
    }

    .app-shell.kq.view-city .mode-selector,
    .app-shell.kq:has(#city-view:not([hidden])) .mode-selector {
      order: 2;
    }

    .app-shell.kq.view-city #game-play-area-card,
    .app-shell.kq:has(#city-view:not([hidden])) #game-play-area-card {
      order: 3;
    }

    .app-shell.kq.view-city #unlocker-card-container,
    .app-shell.kq:has(#city-view:not([hidden])) #unlocker-card-container {
      order: 4;
    }

    .app-shell.kq.view-city .console-panel,
    .app-shell.kq:has(#city-view:not([hidden])) .console-panel {
      display: flex;
      flex-direction: column;
    }

    .app-shell.kq .stats-bar {
      align-items: center;
    }

    .app-shell.kq .mode-selector h3 {
      margin: 0 0 14px;
      line-height: 1.35;
    }

    /* Horizontal mode strip (CI AppMobile) */
    .app-shell.kq .mode-selector .modes-list {
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      gap: 8px;
      overflow-x: auto;
      overflow-y: hidden;
      -webkit-overflow-scrolling: touch;
      scroll-snap-type: x proximity;
      scrollbar-width: none;
      padding-bottom: 4px;
      margin: 0;
      max-width: 100%;
    }

    .app-shell.kq .mode-selector .modes-list::-webkit-scrollbar {
      display: none;
    }

    .app-shell.kq .mode-selector .mode-btn {
      flex: 0 0 84px;
      width: 84px;
      min-width: 84px;
      max-width: 84px;
      flex-direction: column;
      align-items: center;
      justify-content: flex-start;
      text-align: center;
      gap: 7px;
      padding: 11px 6px;
      min-height: 44px;
    }

    /* Adaptive segment tabs (Überblick/Detail + count) */
    .app-shell.kq .segment-selector.adaptive {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      border-radius: var(--radius);
      padding: 6px;
      background: var(--surface-2);
      border: 1px solid var(--line);
    }

    .app-shell.kq .segment-selector.adaptive .segment-btn {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 10px 12px;
      min-height: 44px;
      border-radius: var(--radius-s);
      text-align: left;
      width: 100%;
    }

    .app-shell.kq .segment-selector.adaptive .seg-text {
      flex: 1;
      min-width: 0;
    }

    .app-shell.kq .segment-selector.adaptive .seg-label {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .app-shell.kq .segment-selector.adaptive .seg-count {
      margin-left: auto;
      flex-shrink: 0;
    }

    .app-shell.kq .empty-info {
      align-items: stretch;
      text-align: left;
      padding: 1rem 0.25rem;
    }

    .app-shell.kq .empty-info p {
      max-width: 100%;
      overflow-wrap: anywhere;
      word-break: break-word;
      hyphens: auto;
      line-height: 1.45;
    }

    .app-shell.kq .map-controls {
      padding: 0;
      background: transparent;
      border: none;
      gap: 0;
    }

    .app-shell.kq .map-controls .map-hint {
      display: none !important;
    }

    .app-shell.kq .mode-selector .mode-btn .mode-icon {
      width: 24px;
      height: 24px;
      flex: 0 0 24px;
      border-radius: 8px;
    }

    .app-shell.kq .mode-selector .mode-btn .mode-icon svg {
      width: 20px;
      height: 20px;
    }

    .app-shell.kq .mode-selector .mode-btn > div {
      align-items: center;
      gap: 0;
      min-width: 0;
      width: 100%;
    }

    .app-shell.kq .mode-selector .mode-btn > div span:first-child {
      font-size: 11px;
      line-height: 1.2;
      letter-spacing: 0.02em;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .app-shell.kq .mode-selector .mode-btn > div span:last-child {
      display: none;
    }

    .app-shell.kq .glass-card {
      padding: 14px 16px;
    }

    .app-shell.kq .mode-selector {
      min-width: 0;
      overflow: hidden;
      border: none;
      background: transparent;
      box-shadow: none;
      position: relative;
    }

    .app-shell.kq .mode-selector::after {
      content: '';
      position: absolute;
      z-index: 2;
      pointer-events: none;
      right: 0;
      bottom: 4px;
      width: 44px;
      height: 96px;
      background: linear-gradient(
        to left,
        var(--bg) 0%,
        color-mix(in srgb, var(--bg) 88%, transparent) 42%,
        transparent 100%
      );
    }

    .app-shell.kq .mode-selector.glass-card {
      padding: 0;
    }

    .app-shell.kq .map-center-btn {
      min-height: 36px;
      padding: 5px 11px;
      font-size: 10px;
    }

    .app-shell.kq .control-btn {
      width: 44px;
      height: 44px;
      min-width: 44px;
      min-height: 44px;
    }

    /* Active round: map + play sheet (CI QuizMobile) */
    body.in-round .app-shell.kq.view-city,
    body.in-round .app-shell.kq:has(#city-view:not([hidden])) {
      overflow: hidden;
    }

    body.in-round .app-shell.kq.view-city .dashboard-grid,
    body.in-round .app-shell.kq:has(#city-view:not([hidden])) .dashboard-grid {
      flex: 1 1 auto;
      min-height: 0;
      overflow: hidden;
    }

    body.in-round .app-shell.kq.view-city .map-panel,
    body.in-round .app-shell.kq:has(#city-view:not([hidden])) .map-panel {
      flex: 1 1 0;
      min-height: 0;
      max-height: none;
      grid-template-rows: minmax(0, 1fr);
      grid-template-areas: "mapstack";
    }

    body.in-round .app-shell.kq.view-city .console-panel,
    body.in-round .app-shell.kq:has(#city-view:not([hidden])) .console-panel {
      flex: 0 0 auto;
      max-height: min(46vh, 46dvh);
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      padding-top: 12px;
      padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    body.in-round .app-shell.kq.view-city .segment-selector,
    body.in-round .app-shell.kq.view-city .mode-selector,
    body.in-round .app-shell.kq.view-city #unlocker-card-container,
    body.in-round .app-shell.kq.view-city .console-panel > .glass-card:has(#toggle-progression) {
      display: none !important;
    }

    body.in-round .app-shell.kq.view-city #round-active-ui .prompt-box {
      display: none;
    }

    body.in-round .app-shell.kq.view-city #game-play-area-card {
      max-height: none;
      overflow: visible;
      border: none;
      background: transparent;
      padding: 0;
      box-shadow: none;
    }

    body.in-round .app-shell.kq.view-city #game-play-area-card.glass-card {
      padding: 0;
    }

    body.in-round .app-shell.kq.view-city .map-container-wrapper,
    body.in-round .app-shell.kq:has(#city-view:not([hidden])) .map-container-wrapper {
      width: auto;
      margin: 0;
      height: 100%;
      min-height: min(220px, 34dvh);
      max-height: none;
      border-radius: 0;
      border: none;
      box-shadow: none;
    }

    body.in-round .app-shell.kq.view-city .map-center-btn,
    body.in-round .app-shell.kq:has(#city-view:not([hidden])) .map-center-btn {
      margin: 8px 0 0 max(10px, env(safe-area-inset-left));
    }

    body.in-round .app-shell.kq.view-city .map-prompt-bar,
    body.in-round .app-shell.kq:has(#city-view:not([hidden])) .map-prompt-bar {
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      align-items: center;
      gap: 8px;
      padding: 5px 10px 5px 8px;
      text-align: left;
    }

    body.in-round .app-shell.kq.view-city .map-prompt-bar .map-prompt-title,
    body.in-round .app-shell.kq:has(#city-view:not([hidden])) .map-prompt-bar .map-prompt-title {
      margin: 0;
      flex: 0 0 auto;
      font-size: 8px;
      letter-spacing: 0.06em;
      max-width: 34%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    body.in-round .app-shell.kq.view-city .map-prompt-bar .map-prompt-target,
    body.in-round .app-shell.kq:has(#city-view:not([hidden])) .map-prompt-bar .map-prompt-target {
      flex: 1 1 auto;
      min-width: 0;
      font-size: 0.92rem;
      line-height: 1.15;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    body.in-round .app-shell.kq.view-city .map-prompt-bar .map-prompt-sub,
    body.in-round .app-shell.kq:has(#city-view:not([hidden])) .map-prompt-bar .map-prompt-sub {
      display: none;
    }

    body.in-round .app-shell.kq .choices-grid {
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }

    body.in-round .app-shell.kq .choice-btn {
      min-height: 48px;
      padding: 12px;
      font-size: 14px;
    }

    body.in-round .app-shell.kq .prompt-box .prompt-target {
      font-size: 1.35rem;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
  /* from base.css */
    .dashboard-grid {
      grid-template-columns: 1fr;
    }

    .console-panel {
      order: 2;
    }

    .map-panel {
      order: 1;
    }

    .map-container-wrapper {
      min-height: 420px;
    }

    .hamburg-map-svg,
    .city-map-svg {
      max-height: 55vh;
      max-height: 55dvh;
    }

    .map-prompt-bar {
      display: block;
    }

    body.in-round .segment-selector,
    body.in-round .mode-selector {
      display: none;
    }

    body.in-round .map-container-wrapper {
      flex: 0 1 auto;
      min-height: min(42vh, 42dvh, 320px);
      max-height: min(58vh, 58dvh);
      height: auto;
    }

    body.in-round #round-active-ui .prompt-box {
      display: none;
    }

    body.in-round #game-play-area-card {
      max-height: min(36vh, 36dvh, 280px);
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }

    body.in-round .console-panel {
      order: 3;
    }

    body.in-round .map-panel {
      order: 1;
      min-height: min(52vh, 52dvh);
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
  /* from redesign.css */
    .app-shell.kq.view-hub .dashboard-grid {
      grid-template-columns: 1fr;
      grid-template-rows: auto 1fr;
    }

    .app-shell.kq .choices-grid {
      grid-template-columns: 1fr 1fr;
    }

    .app-shell.kq .stats-bar {
      gap: 6px;
    }

    .app-shell.kq .changelog-header-label {
      display: none;
    }

    .app-shell.kq.view-city .app-header.global-header {
      flex-wrap: wrap;
      gap: 10px;
    }

    .app-shell.kq.view-city .app-header.global-header .stats-bar {
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    .header-city-tabs {
      order: unset;
      flex: 1 1 auto;
      justify-content: flex-start;
    }

    .header-city-menu {
      left: 0;
      transform: none;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
  /* from hub.css */
    .hub-landing-hero {
      grid-template-columns: 1fr;
      gap: 24px;
      padding-top: 16px;
    }

    .hub-landing-visual {
      order: -1;
    }

    .hub-map-frame {
      height: clamp(200px, 36vh, 320px);
    }

    .hub-xp-float {
      left: 12px;
      bottom: -12px;
    }

    .hub-modes-grid {
      grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
  /* from hub.css */
    .hub-about-unified .hub-about-grid {
      grid-template-columns: 1fr;
    }

    .hub-about-unified .hub-about-visual {
      order: -1;
      border-radius: var(--radius, 18px);
    }

    .hub-about-unified .hub-about-kalle {
      border-radius: 0;
    }
}
