/* Anagramatik - Game Styles */
@import url('https://fonts.googleapis.com/css2?family=Denk+One&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background: #eef;
  color: #303030;
  font-family: 'Trebuchet MS', Helvetica, Arial, Verdana, sans-serif;
}

/* --- Game container --- */

#ana-game {
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  background: #eef;
}

/* --- Scorebar --- */

#ana-scorebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: #ccf;
  color: #303030;
  flex-shrink: 0;
  min-height: 36px;
}

#ana-scorebar .score-current {
  font-family: 'Denk One', Arial, sans-serif;
  font-weight: 400;
}

#ana-scorebar .score-best {
  font-family: 'Denk One', Arial, sans-serif;
  font-weight: 400;
  text-align: right;
}

/* --- Board --- */

#ana-board {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.board-grid {
  position: absolute;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--tile-size));
  grid-template-rows: repeat(var(--rows), var(--tile-size));
  gap: var(--gutter);
}

.cell {
  background: #fff;
  border-radius: 1px;
}

/* --- Tiles --- */

.tile {
  position: absolute;
  border-radius: 14%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  cursor: grab;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  z-index: 30;
  /* Glossy highlight */
  background-image:
    linear-gradient(
      170deg,
      rgba(255,255,255,0.45) 0%,
      rgba(255,255,255,0.18) 35%,
      rgba(255,255,255,0.0) 50%,
      rgba(0,0,0,0.06) 75%,
      rgba(0,0,0,0.12) 100%
    );
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.4),
    inset 0 -1px 2px rgba(0,0,0,0.15),
    0 2px 6px rgba(0,0,0,0.2);
}

.tile.dragging {
  cursor: grabbing;
  z-index: 60;
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.4),
    inset 0 -1px 2px rgba(0,0,0,0.15),
    0 8px 24px rgba(0,0,0,0.35);
  transform: scale(1.06);
}

.tile.tidyable {
  outline: 2px dashed rgba(255,255,255,0.6);
  outline-offset: -2px;
}

/* --- Controls bar --- */

#ana-controls {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #ccf;
  flex-shrink: 0;
  padding: 0 8px;
}

#ana-controls button {
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 5px;
  color: #303060;
  padding: 4px 12px;
  font-size: 12px;
  font-family: 'Trebuchet MS', Helvetica, Arial, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s;
}

#ana-controls button:hover {
  background: rgba(255,255,255,0.8);
}

#ana-controls button:active {
  background: rgba(255,255,255,0.95);
}

#ana-controls button:disabled {
  opacity: 0.3;
  cursor: default;
}

/* --- Dialog (status messages at bottom) --- */

#ana-dialog {
  position: fixed;
  bottom: 44px;
  left: 0;
  right: 0;
  z-index: 300;
  pointer-events: none;
  display: flex;
  justify-content: center;
  padding: 0 8px;
}

#ana-dialog .dialog-frame {
  background: #ffa;
  border: 1px solid #339;
  border-radius: 5px;
  box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
  padding: 8px 16px;
  max-width: 90vw;
  font-family: Arial, sans-serif;
  color: #303030;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#ana-dialog .dialog-frame.visible {
  opacity: 0.85;
  transform: translateY(0);
}

/* --- Loading state --- */

#ana-game .loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  font-size: 20px;
  opacity: 0.5;
  color: #303060;
}

/* --- Level advance animation --- */

@keyframes levelUp {
  0% { transform: scale(1); }
  30% { transform: scale(1.15); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.level-up-flash {
  animation: levelUp 0.5s ease-out;
}

/* --- Scores page --- */

#ana-scores {
  width: 100vw;
  height: 100dvh;
  overflow-y: auto;
  background: #eef;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.scores-header {
  width: 100%;
  background: #ccf;
  padding: 16px;
  text-align: center;
  flex-shrink: 0;
}

.scores-header h1 {
  font-family: 'Denk One', Arial, sans-serif;
  font-weight: 400;
  font-size: 24px;
  color: #303030;
}

.scores-date {
  font-size: 14px;
  color: #303060;
  margin-top: 4px;
}

.scores-body {
  width: 100%;
  max-width: 520px;
  padding: 16px;
  flex: 1;
}

.scores-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.scores-table thead th {
  background: #ccf;
  color: #303060;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
}

.scores-table thead th:first-child,
.scores-table tbody td:first-child {
  text-align: center;
  width: 36px;
}

.scores-table thead th:nth-child(3),
.scores-table tbody td:nth-child(3) {
  text-align: right;
  width: 64px;
}

.scores-table tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid #dde;
}

.scores-table tbody tr:nth-child(even) {
  background: rgba(204, 204, 255, 0.15);
}

.scores-table tbody tr.scores-me {
  background: rgba(204, 204, 255, 0.4);
  font-weight: 600;
}

.scores-empty {
  text-align: center;
  padding: 32px 0;
  color: #606080;
  font-size: 16px;
}

.scores-footer {
  width: 100%;
  max-width: 520px;
  padding: 16px;
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-shrink: 0;
}

.scores-footer a {
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 5px;
  color: #303060;
  padding: 8px 16px;
  font-size: 14px;
  font-family: 'Trebuchet MS', Helvetica, Arial, sans-serif;
  text-decoration: none;
  transition: background-color 0.15s;
}

.scores-footer a:hover {
  background: rgba(255,255,255,0.8);
}
