*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #252542;
  --accent: #e94560;
  --accent2: #0f3460;
  --text: #eee;
  --text-dim: #888;
  --card-bg: #1e1e36;
  --card-border: #333;
  --card-selected: #e94560;
  --card-result: #0f3460;
  --red: #e94560;
  --green: #4ade80;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

html, body {
  width: 100%; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.container {
  display: flex; flex-direction: column;
  width: 100%; height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px;
  gap: 12px;
}

/* Header */
.header {
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.header h1 {
  font-size: 22px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #ff6b6b);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.home-btn {
  width: 40px; height: 40px;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  color: var(--text);
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}
.home-btn:active { background: var(--surface2); }

/* Stats bar */
.stats {
  display: flex; gap: 16px; justify-content: center;
  flex-shrink: 0;
  font-size: 14px; color: var(--text-dim);
}
.stats span { display: flex; align-items: center; gap: 4px; }
.stats .value { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Cards area */
.cards-area {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 0;
}

.card {
  width: calc(50% - 6px);
  max-width: 140px;
  aspect-ratio: 2.5/3.5;
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 36px; font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
  position: relative;
}
.card .suit {
  font-size: 18px;
  margin-top: 2px;
  opacity: 0.8;
}
.card.red { color: var(--red); }
.card.black { color: #ccc; }

.card.selected {
  border-color: var(--card-selected);
  box-shadow: 0 0 20px rgba(233,69,96,0.5);
  transform: translateY(-4px);
}
.card.result-card {
  border-color: var(--card-result);
  background: linear-gradient(135deg, #1a1a3e, #252560);
}
.card.used {
  opacity: 0; pointer-events: none;
  transform: scale(0.8);
}
.card:active:not(.used) { transform: scale(0.96); }

/* Operators */
.operators {
  display: flex; gap: 10px; justify-content: center;
  flex-shrink: 0;
  padding: 4px 0;
}
.op-btn {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 2px solid var(--card-border);
  background: var(--surface);
  color: var(--text);
  font-size: 26px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.op-btn:active { background: var(--accent); border-color: var(--accent); }
.op-btn.selected { background: var(--accent); border-color: var(--accent); }

/* Actions */
.actions {
  display: flex; gap: 10px; justify-content: center;
  flex-shrink: 0;
  padding: 4px 0;
}
.action-btn {
  flex: 1; max-width: 120px;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.action-btn:active { background: var(--surface2); }
.action-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Message */
.message {
  text-align: center;
  font-size: 15px;
  min-height: 24px;
  flex-shrink: 0;
  transition: all 0.3s;
}
.message.success { color: var(--green); font-weight: 600; }
.message.error { color: var(--red); font-weight: 600; }
.message.hint-msg { color: #facc15; }
.message.info { color: var(--text-dim); }

/* Hint display */
.hint-display {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: #facc15;
  min-height: 0;
  padding: 0 8px;
  word-break: break-all;
}

/* Animations */
@keyframes pop {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}
.card.animate-in {
  animation: pop 0.3s ease forwards;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.shake { animation: shake 0.3s ease; }

/* Responsive */
@media (max-height: 600px) {
  .container { padding: 8px 12px; gap: 8px; }
  .card { font-size: 28px; }
  .op-btn { width: 50px; height: 50px; font-size: 22px; }
  .action-btn { height: 40px; font-size: 14px; }
}
@media (min-width: 500px) {
  .card { max-width: 160px; font-size: 42px; }
}
