CREATE TABLE games (
  id TEXT PRIMARY KEY,
  rkey TEXT NOT NULL,
  creator_did TEXT NOT NULL,
  player_one TEXT NOT NULL,
  player_two TEXT,
  board_size INTEGER NOT NULL DEFAULT 19,
  status TEXT NOT NULL CHECK(status IN ('waiting', 'active', 'completed')),
  action_count INTEGER NOT NULL DEFAULT 0,
  last_action_type TEXT,
  winner TEXT,
  handicap INTEGER DEFAULT 0,
  created_at TEXT NOT NULL,
  updated_at TEXT NOT NULL
);

CREATE INDEX idx_games_status ON games(status);
CREATE INDEX idx_games_player_one ON games(player_one);
CREATE INDEX idx_games_player_two ON games(player_two);
CREATE INDEX idx_games_rkey ON games(rkey);
CREATE INDEX idx_games_creator_did ON games(creator_did);
