/* -----------------------------------------------------------------
   Material Design 3-inspired UI for DnD Chess
   ----------------------------------------------------------------- */

:root {
  --md-sys-color-primary:            #6750A4;
  --md-sys-color-on-primary:         #FFFFFF;
  --md-sys-color-primary-container:  #EADDFF;
  --md-sys-color-on-primary-container: #21005E;

  --md-sys-color-secondary:          #625B71;
  --md-sys-color-on-secondary:       #FFFFFF;
  --md-sys-color-secondary-container:#E8DEF8;

  --md-sys-color-surface:            #FFFFFF;
  --md-sys-color-surface-variant:    #E7E0EC;
  --md-sys-color-on-surface:         #1C1B1F;
  --md-sys-color-outline:            #938F99;

  --md-sys-color-background:         #F3F2F6;
  --md-sys-color-elevation-1:        rgba(0,0,0,0.05);
  --md-sys-color-elevation-2:        rgba(0,0,0,0.08);

  --radius-l:  16px;
  --radius-m:  12px;
  --radius-s:   8px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Roboto, system-ui, sans-serif;
  background: var(--md-sys-color-background);
  color: var(--md-sys-color-on-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

header {
  width: 100%;
  max-width: 480px;
  padding: 12px 16px;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-radius: 0 0 var(--radius-l) var(--radius-l);
  box-shadow: 0 2px 4px var(--md-sys-color-elevation-2);
  margin-bottom: 16px;
}

main#content {
  width: 100%;
  max-width: 480px;
  padding: 0 16px;
  flex: 1 1 auto;
}

section { margin-bottom: 24px; }

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-s);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, color 0.15s, transform 0.1s;
  text-decoration: none;
}
.action-button:active { transform: scale(0.97); }
.action-button.filled {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.action-button.filled:hover {
  box-shadow: 0 2px 6px var(--md-sys-color-elevation-2);
}
.action-button.outlined {
  border: 1px solid var(--md-sys-color-outline);
  background: transparent;
}
.action-button.text {
  background: transparent;
  color: var(--md-sys-color-primary);
}
.action-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.5rem;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary);
  border: none;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 4px var(--md-sys-color-elevation-2);
  z-index: 4;
}
.fab:hover { box-shadow: 0 4px 8px var(--md-sys-color-elevation-2); }

.icon-button {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.15s;
}
.icon-button:hover {
  background: var(--md-sys-color-elevation-1);
}
.icon-button.material { margin-left: auto; }
.icon-button.material svg { width: 24px; height: 24px; fill: currentColor; }
.material-icons {
  font-size: 1.2rem;
  vertical-align: middle;
}

.room-list-header {
  display: flex;
  align-items: center;
  justify-content: start;
  gap: 8px;
  margin-bottom: 12px;
}
.room-list, .card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.room-card, .bot-card {
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--radius-m);
  padding: 12px 16px;
  box-shadow: 0 1px 2px var(--md-sys-color-elevation-1);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.room-card:hover, .bot-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 6px var(--md-sys-color-elevation-2);
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--radius-s);
  background: var(--md-sys-color-surface);
  font-size: 1rem;
  line-height: 1.3;
  color: var(--md-sys-color-on-surface);
  box-sizing: border-box;
}
input[type="text"]::placeholder {
  color: var(--md-sys-color-outline);
}

.board-wrapper {
  overflow: hidden;
  border-radius: var(--radius-m);
}
#board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  margin: 16px 0;
  border: 1px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-surface-variant);
  border-radius: 0;
}
.square {
  position: relative;
  aspect-ratio: 1/1;
  overflow: hidden;
}
.square.light { background: #F6F6F8; }
.square.dark  { background: #DDE3EA; }

.square img {
  position: absolute;
  width: 90%;
  height: 90%;
  object-fit: contain;
  left: 5%;
  top: 5%;
}

.hp-bar-container {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 6%;
  height: 4%;
  background: #D8D8D8;
  border-radius: 4px;
}
.hp-bar {
  height: 100%;
  border-radius: 4px;
  background: #6A9E63;
  transition: width .2s;
}

.selected-effect {
  outline: 3px solid var(--md-sys-color-primary);
}
.damage-effect   { animation: flash-red   .8s ease-out; }
.heal-effect     { animation: flash-green .8s ease-out; }
@keyframes flash-red   { from {background:#FF8A80;} to {background:inherit;} }
@keyframes flash-green { from {background:#B9F6CA;} to {background:inherit;} }

.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.room-meta {
  flex: 1 1 auto;
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface);
}
.caption {
  font-size: 0.8125rem;
  margin-top: 4px;
}

#ratingsBoard {
  margin-top: 24px;
}
.ratings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.ratings-table th, .ratings-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--md-sys-color-outline);
  text-align: center;
}
.ratings-table thead {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

@media (max-width: 480px) {
  header { border-radius: 0 0 var(--radius-m) var(--radius-m); }
  .action-button { width: 100%; }
  .fab { position: fixed; bottom: 24px; right: calc(50% - 240px + 24px); }
}

.pulse {
  animation: pulseAnim 1.5s infinite;
}
@keyframes pulseAnim {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
