/* =====================================================
   VARÁZSGÉP - CSS
   ===================================================== */

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

:root {
  --bg: #0a1628;
  --bg2: #0e1f3a;
  --card: rgba(20, 50, 90, 0.85);
  --card-border: rgba(74, 175, 212, 0.35);
  --blue: #1e5fa0;
  --blue-light: #4aafd4;
  --gold: #f0d060;
  --green: #2dbe6c;
  --red: #e05555;
  --text: #e0f0ff;
  --text-dim: #7ab0d0;
  --font-main: 'Nunito', sans-serif;
  --font-mono: 'Courier Prime', monospace;
}

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 20%, rgba(30,95,160,0.18) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(45,190,108,0.08) 0%, transparent 50%);
}

/* ---------- HEADER ---------- */
header {
  text-align: center;
  padding: 28px 20px 18px;
  background: linear-gradient(135deg, #0d2a50 0%, #1a4a7a 50%, #0d2a50 100%);
  border-bottom: 2px solid var(--blue-light);
  box-shadow: 0 4px 20px rgba(74,175,212,0.2);
}

header h1 {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(240,208,96,0.5);
  letter-spacing: 2px;
}

header .subtitle {
  margin-top: 10px;
  font-size: 1.05rem;
  color: var(--blue-light);
  font-weight: 600;
}

/* ---------- MAIN LAYOUT ---------- */
main {
  display: flex;
  gap: 20px;
  padding: 24px 20px;
  max-width: 1200px;
  margin: 0 auto;
  align-items: flex-start;
}

/* ---------- PANELS ---------- */
.left-panel {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.center-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.right-panel {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.panel-card h3 {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---------- DIFFICULTY ---------- */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diff-btn, .rule-btn {
  padding: 9px 12px;
  border: 2px solid var(--card-border);
  border-radius: 8px;
  background: rgba(30,50,90,0.6);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.diff-btn:hover, .rule-btn:hover {
  border-color: var(--blue-light);
  background: rgba(74,175,212,0.15);
}

.diff-btn.active[data-diff="easy"] {
  background: rgba(45,190,108,0.25);
  border-color: var(--green);
  color: #a0ffcc;
  box-shadow: 0 0 10px rgba(45,190,108,0.3);
}

.diff-btn.active[data-diff="medium"] {
  background: rgba(240,190,60,0.2);
  border-color: #f0be3c;
  color: #ffe080;
  box-shadow: 0 0 10px rgba(240,190,60,0.3);
}

.diff-btn.active[data-diff="hard"] {
  background: rgba(224,85,85,0.2);
  border-color: var(--red);
  color: #ffaaaa;
  box-shadow: 0 0 10px rgba(224,85,85,0.3);
}

.rule-btn.active {
  background: rgba(74,175,212,0.25);
  border-color: var(--blue-light);
  color: #a8d8f0;
  box-shadow: 0 0 10px rgba(74,175,212,0.3);
}

.diff-info {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
  font-family: var(--font-mono);
}

/* ---------- CENTER: INPUT AREA ---------- */
.input-area {
  width: 100%;
  max-width: 340px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 16px 20px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  margin-bottom: 0;
}

.input-area label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--blue-light);
  margin-bottom: 10px;
}

.input-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.input-area input[type="number"] {
  width: 90px;
  padding: 10px 12px;
  border: 2px solid var(--blue-light);
  border-radius: 8px;
  background: rgba(10,30,60,0.8);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-area input[type="number"]:focus {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(240,208,96,0.3);
}

.error-msg {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--red);
  min-height: 18px;
  font-weight: 700;
}

/* ---------- BUTTONS ---------- */
.btn-primary {
  padding: 10px 20px;
  background: linear-gradient(135deg, #1e5fa0, #2d80c8);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 3px 12px rgba(30,95,160,0.4);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2d80c8, #3a9ae0);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(30,95,160,0.6);
}

.btn-reveal {
  margin-top: 12px;
  padding: 9px 18px;
  background: linear-gradient(135deg, #7a3a20, #c05030);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn-reveal:hover {
  background: linear-gradient(135deg, #c05030, #e06040);
  transform: translateY(-1px);
}

.btn-replay {
  margin-top: 14px;
  background: linear-gradient(135deg, #1a7a40, #2dbe6c);
}

.btn-replay:hover {
  background: linear-gradient(135deg, #2dbe6c, #3de87c);
}

.btn-clear {
  padding: 5px 10px;
  background: rgba(224,85,85,0.2);
  color: #ffaaaa;
  border: 1px solid rgba(224,85,85,0.4);
  border-radius: 6px;
  font-family: var(--font-main);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-clear:hover {
  background: rgba(224,85,85,0.35);
}

/* ---------- ARROWS ---------- */
.arrow-down {
  display: flex;
  justify-content: center;
  margin: 0;
  padding: 4px 0;
}

/* ---------- MACHINE ---------- */
.machine-wrapper {
  position: relative;
  width: 220px;
}

.machine-wrapper svg {
  width: 220px;
  height: 320px;
  display: block;
}

.input-badge, .output-badge {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  padding: 3px 10px;
  border-radius: 6px;
  min-width: 60px;
  text-align: center;
  pointer-events: none;
}

.input-badge {
  top: 2px;
  background: rgba(74,175,212,0.25);
  color: #a8d8f0;
  border: 1px solid rgba(74,175,212,0.4);
}

.output-badge {
  bottom: 2px;
  background: rgba(45,190,108,0.25);
  color: #a0ffcc;
  border: 1px solid rgba(45,190,108,0.4);
}

/* ---------- OUTPUT AREA ---------- */
.output-area {
  width: 100%;
  max-width: 340px;
  text-align: center;
  margin-top: 0;
  padding: 10px 20px;
}

.result-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(45,190,108,0.15);
  border: 2px solid rgba(45,190,108,0.5);
  border-radius: 12px;
  padding: 12px 24px;
  box-shadow: 0 0 16px rgba(45,190,108,0.2);
}

.result-label {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  color: var(--green);
  font-weight: 700;
}

.result-value {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  color: #a0ffcc;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(45,190,108,0.6);
}

/* ---------- GUESS PANEL ---------- */
.guess-panel, .success-panel, .reveal-panel {
  width: 100%;
  max-width: 340px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 18px 20px;
  text-align: center;
  margin-top: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.guess-panel h3 {
  font-size: 1.05rem;
  color: var(--gold);
  margin-bottom: 8px;
}

.guess-panel p {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.guess-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.guess-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.guess-label {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--blue-light);
  font-weight: 700;
}

.guess-input {
  width: 64px;
  padding: 8px 10px;
  border: 2px solid var(--blue-light);
  border-radius: 8px;
  background: rgba(10,30,60,0.8);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.guess-input:focus {
  border-color: var(--gold);
}

.attempts-info {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
  min-height: 16px;
}

.guess-error {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--red);
  font-weight: 700;
  min-height: 18px;
}

/* ---------- SUCCESS / REVEAL ---------- */
.success-msg {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--green);
  text-shadow: 0 0 16px rgba(45,190,108,0.6);
  margin-bottom: 10px;
}

.reveal-msg {
  font-size: 1rem;
  font-weight: 700;
  color: #ffaaaa;
  margin-bottom: 10px;
}

.revealed-formula {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--gold);
  font-weight: 700;
  text-shadow: 0 0 12px rgba(240,208,96,0.5);
  margin-bottom: 8px;
}

/* ---------- TABLE ---------- */
.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.table-container {
  max-height: 220px;
  overflow-y: auto;
  border-radius: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--blue-light) transparent;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

thead th {
  background: rgba(74,175,212,0.2);
  color: var(--gold);
  font-weight: 700;
  padding: 7px 14px;
  text-align: center;
  border-bottom: 1px solid var(--blue-light);
}

tbody td {
  padding: 6px 14px;
  text-align: center;
  color: var(--text);
  border-bottom: 1px solid rgba(74,175,212,0.1);
}

tbody tr:hover td {
  background: rgba(74,175,212,0.08);
}

.empty-row td {
  color: var(--text-dim);
  font-style: italic;
  font-family: var(--font-main);
  font-size: 0.82rem;
}

/* ---------- CHART ---------- */
.chart-panel { }

.chart-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}

.chart-toggle-row h3 {
  margin-bottom: 0;
}

.btn-toggle-chart {
  padding: 5px 10px;
  background: rgba(74,175,212,0.15);
  color: var(--blue-light);
  border: 1px solid rgba(74,175,212,0.4);
  border-radius: 6px;
  font-family: var(--font-main);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle-chart:hover {
  background: rgba(74,175,212,0.3);
}

.chart-container {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  transition: all 0.3s ease;
}

#coordCanvas {
  border-radius: 8px;
  background: rgba(8,18,40,0.9);
  border: 1px solid rgba(74,175,212,0.3);
  width: 100%;
  max-width: 280px;
  height: auto;
  aspect-ratio: 1;
}

/* ---------- CONFETTI ---------- */
#confettiCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
  main {
    flex-direction: column;
    align-items: center;
  }
  .left-panel, .right-panel {
    width: 100%;
    max-width: 400px;
  }
  .btn-group {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .diff-btn, .rule-btn {
    flex: 1;
    text-align: center;
  }
}
