:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --ink: DarkSlateGray;
  --muted: #000099;
  --blank: #ffffff;
  --blue: #1868d0;
  --red: #f00080;
  --line: rgba(0, 0, 255, 1);
  --tile-line: rgba(0, 0, 255, 0.9);
  --tile-line-width: 4px;
}


* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  color: var(--ink);
  background:
  var(--bg);
}

button {
  font: inherit;
}

.app {
  width: min(94vw, 840px);
  display: grid;
  grid-template-columns: minmax(280px, 520px) minmax(180px, 240px);
  gap: 18px;
  align-items: start;
}

.game,
.controls {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 8px;
}

.game {
  padding: 18px;
}

.controls {
  padding: 10px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

h2 {
  margin: 0.4rem;
  font-size: 1.3rem;
  letter-spacing: 0;
}

a {
  color: #00b0f0;
}


.selected-name {
  min-height: 1.2em;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 1.3rem;
  font-weight: bold;
}

.counter {
  width: 74px;
  aspect-ratio: 2;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
}

.counter span {
  line-height: 1;
  font-size: 1.45rem;
  font-weight: 800;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  aspect-ratio: 1;
  background: var(--blank);
  padding: 8px;
  border-radius: 8px;
}

.tile {
  position: relative;
  min-width: 0;
  border: none;
  border-radius: 6px;
  color: transparent;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.tile:hover {
  transform: translateY(-1px);
}

.tile.image-tile {
  background-size: 400% 400%;
  background-repeat: no-repeat;
  overflow: hidden;
}

.tile.image-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-color: var(--tile-line);
  border-radius: inherit;
  border-style: solid;
  border-width: var(--edge-top) var(--edge-right) var(--edge-bottom) var(--edge-left);
  pointer-events: none;
}

.tile.blank {
  background: transparent;
  cursor: default;
}

.image-choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.image-choice {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 3px solid transparent;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.image-choice.active {
  border-color: var(--red);
}

.image-choice img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.shuffle-button {
  width: 100%;
  border: none;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 1.0rem;
  font-weight: 800;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
  text-align: center;
}

.message {
  min-height: 1.2em;
  margin: 12px 0 0;
  font-size: 1.2rem;
}

@media (max-width: 720px) {
  body {
    align-items: start;
    padding: 14px;
  }

  .app {
    grid-template-columns: 1fr;
  }

  .controls {
    order: -1;
  }

  .image-choices {
    grid-template-columns: repeat(4, 1fr);
  }
}
