/* style.css - Clean & Functional Mobile UI + In-App Scanner + Direct Inputs */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@600&family=IBM+Plex+Sans:wght@400;600;700&display=swap');

:root {
  --color-bg: #f4f1ea;       
  --color-surface: #ffffff;  
  --color-ink: #111111;      
  --color-accent: #1c7a4b;   
  --color-stamp: #d93829;    
  --color-muted: #6b7280;
  --color-border: #e5e7eb;   

  --font-sans: 'IBM Plex Sans', sans-serif;
  --font-display: 'IBM Plex Mono', monospace;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 16px;
  --sp-4: 24px;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

/* === BULLETPROOF IOS RESET === */
html {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

*, *:before, *:after { 
  box-sizing: inherit; 
}

* { 
  margin: 0; 
  padding: 0; 
  touch-action: manipulation; 
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-ink);
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;       
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  position: relative;
}

/* === HEADER === */
header {
  padding: env(safe-area-inset-top, 16px) 16px 16px;
  background: var(--color-surface);
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.5px;
  border-bottom: 1px solid var(--color-border);
  z-index: 10;
  width: 100%;
}

/* === MAIN CONTENT === */
main {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-3);
  -webkit-overflow-scrolling: touch; 
}

.view { display: none; width: 100%; }
.view.active { display: block; animation: fadeUp 0.2s ease-out; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === UI CARDS === */
.card {
  background: var(--color-surface);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0,0,0,0.02);
  width: 100%;
}

.card h3 { 
  margin-bottom: var(--sp-2); 
  font-size: 1.1rem; 
  font-weight: 700; 
}

.card h4 { 
  margin-bottom: var(--sp-2); 
  font-size: 1rem; 
  color: var(--color-muted);
}

/* === BUTTONS === */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent);
  color: #ffffff;
  border: none;
  padding: 14px var(--sp-3); 
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  width: 100%;
  margin-top: var(--sp-2);
  transition: transform 0.1s ease, opacity 0.2s ease;
}

.btn:active { 
  transform: scale(0.97); 
}

.btn:disabled { 
  background: var(--color-border); 
  color: var(--color-muted); 
}

#btn-reset {
  background: #fff0f0;
  color: var(--color-stamp);
  border: 1px solid #ffd6d6;
}

/* === SPIEL-DASHBOARD (Input) === */
.draw-section { 
  display: flex; 
  gap: var(--sp-2); 
  align-items: center;
  width: 100%;
}

.draw-section input {
  flex: 1;
  min-width: 0; 
  font-family: var(--font-display);
  font-size: 1.8rem;
  text-align: center;
  border: 2px solid var(--color-border);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 10px var(--sp-1);
  outline: none;
  color: var(--color-ink);
  transition: border-color 0.2s;
}

.draw-section input:focus {
  border-color: var(--color-accent);
  background: var(--color-surface);
}

.draw-section button { 
  flex: 1; 
  min-width: 0; 
  margin-top: 0; 
  height: 100%;
}

/* === HISTORIE (Optimiert für Horizontal Scroll) === */
.history {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  justify-content: flex-start;
  flex-wrap: nowrap;
  overflow-x: auto; /* Erlaubt das Wischen nach rechts/links */
  padding-bottom: var(--sp-2);
  align-items: center;
  /* Versteckt die Scrollbar für einen cleanen Look */
  scrollbar-width: none; 
  -ms-overflow-style: none;
}
.history::-webkit-scrollbar {
  display: none;
}
.history-empty {
  color: var(--color-muted);
  font-size: 0.95rem;
  text-align: center;
  width: 100%;
  padding: var(--sp-2) 0;
}
.history .ball {
  flex: 0 0 auto; /* Verhindert das Quetschen der Bälle */
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--color-ink);
}
.history .ball-letter {
  font-family: var(--font-sans);
  font-size: 0.6rem;
  color: var(--color-muted);
  font-weight: 700;
  margin-bottom: 2px;
}
.history .ball.latest {
  width: 58px;
  height: 58px;
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
  box-shadow: 0 4px 12px rgba(28, 122, 75, 0.3);
  font-size: 1.3rem;
}
.history .ball.latest .ball-letter {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.7rem;
}

/* === BINGO RASTER === */
.bingo-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  background: var(--color-surface);
  width: 100%;
}

.grid-header {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  padding: var(--sp-1) 0;
  font-size: 1rem;
  color: var(--color-muted);
}

.cell {
  aspect-ratio: 1;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  position: relative;
  transition: transform 0.1s ease;
  border: 1px solid rgba(0,0,0,0.04);
}

.cell:active { transform: scale(0.92); } 

.cell.marked::after {
  content: "";
  position: absolute;
  width: 80%;
  height: 80%;
  border: 3px solid var(--color-stamp);
  border-radius: 40% 60% 50% 40% / 50% 45% 60% 55%;
  transform: scale(0) rotate(-15deg);
  pointer-events: none; 
  animation: stampIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes stampIn {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  100% { transform: scale(1) rotate(5deg); opacity: 0.85; }
}

.cell.active-draft {
  background: rgba(28, 122, 75, 0.1);
  border: 2px solid var(--color-accent);
  color: var(--color-accent);
}

/* === OCR POOL === */
.pool {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: var(--sp-3);
  justify-content: center;
}
.pool-number {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 10px 18px;
  border-radius: 99px; 
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  cursor: pointer;
  transition: all 0.1s;
}
.pool-number:active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
  transform: scale(0.95);
}

.error { 
  color: var(--color-stamp); 
  font-size: 0.9rem; 
  font-weight: 600; 
  margin-top: var(--sp-2); 
  text-align: center;
}

/* === NAVIGATION === */
nav {
  display: flex;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-bottom: env(safe-area-inset-bottom, 16px); 
  z-index: 10;
  width: 100%;
}
nav button {
  flex: 1;
  padding: 16px var(--sp-2);
  background: none;
  border: none;
  color: var(--color-muted);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  transition: color 0.2s;
  position: relative;
}

nav button.active {
  color: var(--color-accent);
}

nav button.active::after {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: var(--color-accent);
  border-radius: 0 0 4px 4px;
}

/* === IN-APP SCANNER OVERLAY === */
.scanner-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none; 
  z-index: 10;
  overflow: hidden;
}

.scanner-frame {
  width: 70%; 
  aspect-ratio: 5 / 6; 
  border: 3px solid var(--color-accent);
  border-radius: 8px;
  outline: 4000px solid rgba(0, 0, 0, 0.6); 
  position: relative;
}

.scanner-frame::before, .scanner-frame::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-color: #fff; border-style: solid;
}
.scanner-frame::before { top: -3px; left: -3px; border-width: 3px 0 0 3px; }
.scanner-frame::after { bottom: -3px; right: -3px; border-width: 0 3px 3px 0; }

/* === ANPASSUNGEN FÜR DIREKTE RASTER-EINGABE === */
input.cell {
  text-align: center;
  color: var(--color-ink);
  outline: none;
  -webkit-appearance: none;
  margin: 0;
  width: 100%;
  border: 1px solid rgba(0,0,0,0.04);
}

input.cell:focus {
  border: 2px solid var(--color-accent);
  background: rgba(28, 122, 75, 0.05);
}

input.cell::-webkit-outer-spin-button,
input.cell::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input.cell[type=number] {
  -moz-appearance: textfield;
}
