:root {
  --bg: #f4f6f8;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --tile-bg: #ffffff;
  --tile-border: #d0d7de;
  --text: #1a1a1a;
  --danger: #dc2626;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  height: 100%;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100vh;
  width: 100%;
}

/* ---------- Login ---------- */

#login-screen,
#admin-login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  background: var(--tile-bg);
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-box h1 {
  margin: 0 0 8px;
  font-size: 2.2rem;
}

.login-box label {
  font-size: 1.3rem;
  text-align: left;
}

.login-box input {
  font-size: 1.6rem;
  padding: 16px;
  border: 2px solid var(--tile-border);
  border-radius: 10px;
  width: 100%;
}

.login-box button {
  font-size: 1.6rem;
  padding: 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.login-box button:hover {
  background: var(--accent-dark);
}

.login-box .error {
  color: var(--danger);
  font-size: 1.2rem;
  font-weight: bold;
}

/* ---------- Main / toolbar ---------- */

.toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px;
}

.toolbar-button {
  font-size: 1.2rem;
  padding: 14px 22px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: white;
}

.logout-button {
  background: #64748b;
}

.logout-button:hover {
  background: #475569;
}

/* ---------- Tiles grid ---------- */

.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  padding: 8px 16px 32px;
}

.tile {
  background: var(--tile-bg);
  border: 3px solid var(--tile-border);
  border-radius: 16px;
  min-width: 120px;
  min-height: 120px;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}

.tile:hover {
  border-color: var(--accent);
}

.tile:active {
  transform: scale(0.96);
}

.tile .emoji {
  font-size: 3rem;
  line-height: 1;
}

.tile .label {
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  word-break: break-word;
}

.tile.playing {
  border-color: var(--accent);
  background: #eaf1ff;
  animation: pulse 0.9s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5); }
  50% { box-shadow: 0 0 0 10px rgba(37, 99, 235, 0); }
}

@media (min-width: 900px) {
  .tiles-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
  .tile .emoji {
    font-size: 3.6rem;
  }
  .tile .label {
    font-size: 1.25rem;
  }
}

/* ---------- Admin ---------- */

#admin-main-screen .toolbar {
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.admin-title {
  margin: 0;
  font-size: 1.6rem;
  flex: 1 1 auto;
}

.refresh-button {
  background: var(--accent);
}

.refresh-button:hover {
  background: var(--accent-dark);
}

.admin-content {
  padding: 0 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.log-section h2 {
  font-size: 1.3rem;
  margin: 0 0 12px;
}

details.log-section > summary {
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

details.log-section > summary::-webkit-details-marker {
  display: none;
}

details.log-section > summary::before {
  content: "▶";
  display: inline-block;
  margin-right: 10px;
  font-size: 0.9rem;
  transition: transform 0.15s ease;
}

details.log-section[open] > summary::before {
  transform: rotate(90deg);
}

details.log-section .table-wrap {
  margin-top: 12px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.filter-bar input,
.filter-bar select {
  font-size: 1rem;
  padding: 10px 12px;
  border: 2px solid var(--tile-border);
  border-radius: 8px;
  background: var(--tile-bg);
  color: var(--text);
}

.filter-bar input[type="search"] {
  flex: 1 1 220px;
}

.filter-clear-button {
  font-size: 1rem;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: #64748b;
  color: white;
  cursor: pointer;
}

.filter-clear-button:hover {
  background: #475569;
}

.table-wrap {
  overflow-x: auto;
  background: var(--tile-bg);
  border: 2px solid var(--tile-border);
  border-radius: 12px;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

.log-table th,
.log-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--tile-border);
  white-space: nowrap;
}

.log-table th {
  background: #eef2f7;
  font-weight: 700;
}

.log-table tbody tr:last-child td {
  border-bottom: none;
}

.result-ok {
  color: #16a34a;
  font-weight: 700;
}

.result-fail {
  color: var(--danger);
  font-weight: 700;
}
